Skip to content

Commit fa82549

Browse files
committed
new/delete and fprintf
1 parent 9cdbbee commit fa82549

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/common.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int32_t get_num_physical_cores() {
6060
GetLogicalProcessorInformationEx(RelationAll, nullptr, &length);
6161

6262
// Allocate memory for the buffer
63-
buffer = static_cast<SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *>(malloc(length));
63+
buffer = reinterpret_cast<SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *>(new char[length]);
6464

6565
// Things to count
6666
unsigned int physical_cores = 0;
@@ -108,10 +108,10 @@ int32_t get_num_physical_cores() {
108108
physical_cores, physical_performance_cores, physical_efficiency_cores,
109109
logical_cores, logical_performance_cores, logical_efficiency_cores);
110110
} else {
111-
printf("Failed to get processor information. Error: %u\n", GetLastError());
111+
fprintf(stderr, "Failed to get processor information. Error: %u\n", GetLastError());
112112
}
113113

114-
free(buffer);
114+
delete[] buffer;
115115

116116
if (physical_performance_cores > 0) {
117117
return static_cast<int32_t>(physical_performance_cores);

0 commit comments

Comments
 (0)