From 33492be5db5d801d8fab5d0e01fc2c372c6ec9f6 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Tue, 13 May 2014 19:06:13 +0200 Subject: gf_inline_time.c: fix memory leak Free all with malloc allocated memory before exit. Change if checks against 'w' to be a if-else check to prevent checking after already matched. Signed-off-by: Danny Al-Gaaf --- tools/gf_inline_time.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/gf_inline_time.c b/tools/gf_inline_time.c index c81e8a9..f8119da 100644 --- a/tools/gf_inline_time.c +++ b/tools/gf_inline_time.c @@ -116,8 +116,7 @@ int main(int argc, char **argv) printf("Inline mult: %10.6lf s Mops: %10.3lf %10.3lf Mega-ops/s\n", elapsed, dnum/1024.0/1024.0, dnum/1024.0/1024.0/elapsed); - } - if (w == 8) { + } else if (w == 8) { mult8 = gf_w8_get_mult_table(&gf); if (mult8 == NULL) { printf("Couldn't get inline multiplication table.\n"); @@ -139,8 +138,7 @@ int main(int argc, char **argv) } printf("Inline mult: %10.6lf s Mops: %10.3lf %10.3lf Mega-ops/s\n", elapsed, dnum/1024.0/1024.0, dnum/1024.0/1024.0/elapsed); - } - if (w == 16) { + } else if (w == 16) { log16 = gf_w16_get_log_table(&gf); alog16 = gf_w16_get_mult_alog_table(&gf); if (log16 == NULL) { @@ -164,5 +162,9 @@ int main(int argc, char **argv) printf("Inline mult: %10.6lf s Mops: %10.3lf %10.3lf Mega-ops/s\n", elapsed, dnum/1024.0/1024.0, dnum/1024.0/1024.0/elapsed); } + free (ra); + free (rb); + free (ra16); + free (rb16); return 0; } -- cgit v1.2.1