Fix bug and memory leak

This commit is contained in:
Dr-Noob
2020-06-22 18:00:45 +02:00
parent 7fee305e8b
commit 698274e44c
3 changed files with 7 additions and 1 deletions

View File

@@ -130,6 +130,7 @@ int main(int argc, char* argv[]) {
free(cpu); free(cpu);
free(art); free(art);
free_cache_struct(cach); free_cache_struct(cach);
free_topo_struct(topo);
free_freq_struct(freq); free_freq_struct(freq);
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@@ -198,7 +198,7 @@ struct cpuInfo* get_cpu_info() {
} }
struct topology* get_topology_info(struct cpuInfo* cpu) { struct topology* get_topology_info(struct cpuInfo* cpu) {
struct topology* topo = malloc(sizeof(struct cache)); struct topology* topo = malloc(sizeof(struct topology));
uint32_t eax = 0; uint32_t eax = 0;
uint32_t ebx = 0; uint32_t ebx = 0;
uint32_t ecx = 0; uint32_t ecx = 0;
@@ -703,6 +703,10 @@ void print_levels(struct cpuInfo* cpu, char* cpu_name) {
printf("- Max extended level: 0x%.8X\n", cpu->maxExtendedLevels); printf("- Max extended level: 0x%.8X\n", cpu->maxExtendedLevels);
} }
void free_topo_struct(struct topology* topo) {
free(topo);
}
void free_cache_struct(struct cache* cach) { void free_cache_struct(struct cache* cach) {
free(cach); free(cach);
} }

View File

@@ -45,6 +45,7 @@ void print_levels(struct cpuInfo* cpu, char* cpu_name);
void free_cpuinfo_struct(struct cpuInfo* cpu); void free_cpuinfo_struct(struct cpuInfo* cpu);
void free_cache_struct(struct cache* cach); void free_cache_struct(struct cache* cach);
void free_topo_struct(struct topology* topo);
void free_freq_struct(struct frequency* freq); void free_freq_struct(struct frequency* freq);
void debug_cpu_info(struct cpuInfo* cpu); void debug_cpu_info(struct cpuInfo* cpu);