OSSP CVS Repository

ossp - Check-in [1583]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1583
Date: 2002-Jan-18 19:12:33 (local)
2002-Jan-18 18:12:33 (UTC)
User:rse
Branch:
Comment: fix memory leak
Tickets:
Inspections:
Files:
ossp-pkg/val/val.c      1.6 -> 1.7     5 inserted, 2 deleted

ossp-pkg/val/val.c 1.6 -> 1.7

--- val.c        2002/01/17 12:19:09     1.6
+++ val.c        2002/01/18 18:12:33     1.7
@@ -516,7 +516,7 @@
 /* destroy the whole hash table */
 static int lh_destroy(lh_t *h)
 {
-    element_t *el, **pel;
+    element_t *el, **pel, *el_next;
     unsigned int i, j;
 
     /* argument consistency check */
@@ -533,10 +533,13 @@
                 continue;
             /* deallocate all elements in collision chain */
             pel = &h->h_dir[i]->s_element[j];
-            for (el = *pel; el != NULL; el = el->e_next) {
+            for (el = *pel; el != NULL; ) {
                 /* deallocate key+data memory chunk */
                 if (el->e_keyptr != NULL)
                     free(el->e_keyptr);
+                el_next = el->e_next;
+                free(el);
+                el = el_next;
             }
         }
         free(h->h_dir[i]);

CVSTrac 2.0.1