[alpha_beta] Fix memory leaks
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 13:57:47 +0200
changeset 87 b2f1756c17ca
parent 86 86b83a979d9e
child 88 91fbc3ea240b
[alpha_beta] Fix memory leaks I have used many mallocs and have not freed it. But there is still a read error which indicates another problem. committer: Markus Bröker <mbroeker@largo.homelinux.org>
alpha_beta.c
--- a/alpha_beta.c
+++ b/alpha_beta.c
@@ -74,6 +74,7 @@
     board[stack_end->data->target] = EMPTY;
 
     actual = stack_end->prev;
+    free (stack_end->data);
     free (stack_end);
 
     stack_end = actual;
@@ -340,6 +341,7 @@
         print ();
 
         if ((estimateFunction () * estimateFunction ()) == 2500) {
+            free (actual);
             return EXIT_SUCCESS;
         }
 
@@ -348,6 +350,7 @@
     }
 
     print ();
+    free (actual);
 
     return EXIT_SUCCESS;
 }