File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ int32_t get_num_physical_cores() {
60
60
GetLogicalProcessorInformationEx (RelationAll, nullptr , &length);
61
61
62
62
// 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] );
64
64
65
65
// Things to count
66
66
unsigned int physical_cores = 0 ;
@@ -108,10 +108,10 @@ int32_t get_num_physical_cores() {
108
108
physical_cores, physical_performance_cores, physical_efficiency_cores,
109
109
logical_cores, logical_performance_cores, logical_efficiency_cores);
110
110
} else {
111
- printf ( " Failed to get processor information. Error: %u\n " , GetLastError ());
111
+ fprintf (stderr, " Failed to get processor information. Error: %u\n " , GetLastError ());
112
112
}
113
113
114
- free ( buffer) ;
114
+ delete[] buffer;
115
115
116
116
if (physical_performance_cores > 0 ) {
117
117
return static_cast <int32_t >(physical_performance_cores);
You can’t perform that action at this time.
0 commit comments