From 6ee7bb4f7b08a9b90154bd0bc336206218cffc21 Mon Sep 17 00:00:00 2001 From: Calvin Hill Date: Thu, 16 May 2019 02:54:21 +0100 Subject: [PATCH] cpu_type.h: Allow cpu_type functions to be accessible from C. This allows cpu_type.h to be used in C-based software, with the get_cpu_*() functions all accessible via C as well as C++ code. Tested changes with sysinfo, AboutHaiku and Pulse. Change-Id: Ide87d8e3f2ba5f0f1890f385b1ac90c677bcc274 Reviewed-on: https://review.haiku-os.org/c/1453 Reviewed-by: waddlesplash --- headers/private/shared/cpu_type.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/headers/private/shared/cpu_type.h b/headers/private/shared/cpu_type.h index a33125f6fc..8a71c9fabe 100644 --- a/headers/private/shared/cpu_type.h +++ b/headers/private/shared/cpu_type.h @@ -483,7 +483,7 @@ get_cpu_type(char *vendorBuffer, size_t vendorSize, char *modelBuffer, cpu_topology_node_info* topology = NULL; get_cpu_topology_info(NULL, &topologyNodeCount); if (topologyNodeCount != 0) - topology = new cpu_topology_node_info[topologyNodeCount]; + topology = (cpu_topology_node_info*)calloc(topologyNodeCount, sizeof(cpu_topology_node_info)); get_cpu_topology_info(topology, &topologyNodeCount); enum cpu_platform platform = B_CPU_UNKNOWN; @@ -507,7 +507,7 @@ get_cpu_type(char *vendorBuffer, size_t vendorSize, char *modelBuffer, break; } } - delete[] topology; + free(topology); vendor = get_cpu_vendor_string(cpuVendor); if (vendor == NULL) @@ -529,7 +529,7 @@ get_rounded_cpu_speed(void) cpu_topology_node_info* topology = NULL; get_cpu_topology_info(NULL, &topologyNodeCount); if (topologyNodeCount != 0) - topology = new cpu_topology_node_info[topologyNodeCount]; + topology = (cpu_topology_node_info*)calloc(topologyNodeCount, sizeof(cpu_topology_node_info)); get_cpu_topology_info(topology, &topologyNodeCount); uint64 cpuFrequency = 0; @@ -539,7 +539,7 @@ get_rounded_cpu_speed(void) break; } } - delete[] topology; + free(topology); int target, frac, delta; int freqs[] = { 100, 50, 25, 75, 33, 67, 20, 40, 60, 80, 10, 30, 70, 90 };