223 assert(process_query != NULL, "invariant"); |
223 assert(process_query != NULL, "invariant"); |
224 return allocate_counters(&process_query->set, nofCounters); |
224 return allocate_counters(&process_query->set, nofCounters); |
225 } |
225 } |
226 |
226 |
227 static void deallocate_counters(MultiCounterQueryP query) { |
227 static void deallocate_counters(MultiCounterQueryP query) { |
228 if (query->counters != NULL) { |
228 FREE_C_HEAP_ARRAY(char, query->counters); |
229 FREE_C_HEAP_ARRAY(char, query->counters); |
229 query->counters = NULL; |
230 query->counters = NULL; |
230 query->noOfCounters = 0; |
231 query->noOfCounters = 0; |
|
232 } |
|
233 } |
231 } |
234 |
232 |
235 static OSReturn add_counter(UpdateQueryP query, HCOUNTER* counter, const char* path, bool first_sample_on_init) { |
233 static OSReturn add_counter(UpdateQueryP query, HCOUNTER* counter, const char* path, bool first_sample_on_init) { |
236 assert(query != NULL, "invariant"); |
234 assert(query != NULL, "invariant"); |
237 assert(counter != NULL, "invariant"); |
235 assert(counter != NULL, "invariant"); |
657 dot_pos[0] = '\0'; |
655 dot_pos[0] = '\0'; |
658 return process_image_name; |
656 return process_image_name; |
659 } |
657 } |
660 |
658 |
661 static void deallocate_pdh_constants() { |
659 static void deallocate_pdh_constants() { |
662 if (process_image_name != NULL) { |
660 FREE_C_HEAP_ARRAY(char, process_image_name); |
663 FREE_C_HEAP_ARRAY(char, process_image_name); |
661 process_image_name = NULL; |
664 process_image_name = NULL; |
662 FREE_C_HEAP_ARRAY(char, pdh_IDProcess_counter_fmt); |
665 } |
663 pdh_IDProcess_counter_fmt = NULL; |
666 if (pdh_IDProcess_counter_fmt != NULL) { |
|
667 FREE_C_HEAP_ARRAY(char, pdh_IDProcess_counter_fmt); |
|
668 pdh_IDProcess_counter_fmt = NULL; |
|
669 } |
|
670 } |
664 } |
671 |
665 |
672 static int allocate_pdh_constants() { |
666 static int allocate_pdh_constants() { |
673 assert(process_image_name == NULL, "invariant"); |
667 assert(process_image_name == NULL, "invariant"); |
674 const char* pdh_image_name = pdh_process_image_name(); |
668 const char* pdh_image_name = pdh_process_image_name(); |
1350 return true; |
1344 return true; |
1351 } |
1345 } |
1352 |
1346 |
1353 CPUInformationInterface::~CPUInformationInterface() { |
1347 CPUInformationInterface::~CPUInformationInterface() { |
1354 if (_cpu_info != NULL) { |
1348 if (_cpu_info != NULL) { |
1355 const char* cpu_name = _cpu_info->cpu_name(); |
1349 FREE_C_HEAP_ARRAY(char, _cpu_info->cpu_name()); |
1356 if (cpu_name != NULL) { |
1350 _cpu_info->set_cpu_name(NULL); |
1357 FREE_C_HEAP_ARRAY(char, cpu_name); |
1351 FREE_C_HEAP_ARRAY(char, _cpu_info->cpu_description()); |
1358 _cpu_info->set_cpu_name(NULL); |
1352 _cpu_info->set_cpu_description(NULL); |
1359 } |
|
1360 const char* cpu_desc = _cpu_info->cpu_description(); |
|
1361 if (cpu_desc != NULL) { |
|
1362 FREE_C_HEAP_ARRAY(char, cpu_desc); |
|
1363 _cpu_info->set_cpu_description(NULL); |
|
1364 } |
|
1365 delete _cpu_info; |
1353 delete _cpu_info; |
1366 _cpu_info = NULL; |
1354 _cpu_info = NULL; |
1367 } |
1355 } |
1368 } |
1356 } |
1369 |
1357 |