From 698274e44ca2c1de868671a650b8678237d27ea2 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Mon, 22 Jun 2020 18:00:45 +0200 Subject: [PATCH] Fix bug and memory leak --- src/main.c | 1 + src/standart.c | 6 +++++- src/standart.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 050a85b..f91b908 100644 --- a/src/main.c +++ b/src/main.c @@ -130,6 +130,7 @@ int main(int argc, char* argv[]) { free(cpu); free(art); free_cache_struct(cach); + free_topo_struct(topo); free_freq_struct(freq); return EXIT_SUCCESS; diff --git a/src/standart.c b/src/standart.c index 489cd70..1e908d0 100644 --- a/src/standart.c +++ b/src/standart.c @@ -198,7 +198,7 @@ struct cpuInfo* get_cpu_info() { } 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 ebx = 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); } +void free_topo_struct(struct topology* topo) { + free(topo); +} + void free_cache_struct(struct cache* cach) { free(cach); } diff --git a/src/standart.h b/src/standart.h index 7c7ac5f..caa0b9f 100644 --- a/src/standart.h +++ b/src/standart.h @@ -45,6 +45,7 @@ void print_levels(struct cpuInfo* cpu, char* cpu_name); void free_cpuinfo_struct(struct cpuInfo* cpu); void free_cache_struct(struct cache* cach); +void free_topo_struct(struct topology* topo); void free_freq_struct(struct frequency* freq); void debug_cpu_info(struct cpuInfo* cpu);