Commit 33492be5db5d801d8fab5d0e01fc2c372c6ec9f6

Authored by Danny Al-Gaaf
1 parent 9d53ea59
Exists in master and in 3 other branches v2, v3, wip-18092

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 <danny.al-gaaf@bisect.de>
Showing 1 changed file with 6 additions and 4 deletions   Show diff stats
tools/gf_inline_time.c
... ... @@ -116,8 +116,7 @@ int main(int argc, char **argv)
116 116 printf("Inline mult: %10.6lf s Mops: %10.3lf %10.3lf Mega-ops/s\n",
117 117 elapsed, dnum/1024.0/1024.0, dnum/1024.0/1024.0/elapsed);
118 118  
119   - }
120   - if (w == 8) {
  119 + } else if (w == 8) {
121 120 mult8 = gf_w8_get_mult_table(&gf);
122 121 if (mult8 == NULL) {
123 122 printf("Couldn't get inline multiplication table.\n");
... ... @@ -139,8 +138,7 @@ int main(int argc, char **argv)
139 138 }
140 139 printf("Inline mult: %10.6lf s Mops: %10.3lf %10.3lf Mega-ops/s\n",
141 140 elapsed, dnum/1024.0/1024.0, dnum/1024.0/1024.0/elapsed);
142   - }
143   - if (w == 16) {
  141 + } else if (w == 16) {
144 142 log16 = gf_w16_get_log_table(&gf);
145 143 alog16 = gf_w16_get_mult_alog_table(&gf);
146 144 if (log16 == NULL) {
... ... @@ -164,5 +162,9 @@ int main(int argc, char **argv)
164 162 printf("Inline mult: %10.6lf s Mops: %10.3lf %10.3lf Mega-ops/s\n",
165 163 elapsed, dnum/1024.0/1024.0, dnum/1024.0/1024.0/elapsed);
166 164 }
  165 + free (ra);
  166 + free (rb);
  167 + free (ra16);
  168 + free (rb16);
167 169 return 0;
168 170 }
... ...