fixed memory leak in ucx_map_rehash

Fri, 12 Oct 2012 12:00:06 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 12 Oct 2012 12:00:06 +0200
changeset 70
6721482eaf8e
parent 69
fb59270b1de3
child 72
bb3eae81aae8

fixed memory leak in ucx_map_rehash

ucx/map.c file | annotate | diff | comparison | revisions
ucx/test.h file | annotate | diff | comparison | revisions
--- a/ucx/map.c	Fri Oct 12 10:54:55 2012 +0200
+++ b/ucx/map.c	Fri Oct 12 12:00:06 2012 +0200
@@ -28,7 +28,7 @@
     return map;
 }
 
-void ucx_map_free(UcxMap *map) {
+void ucx_map_free_elmlist(UcxMap *map) {
     for (size_t n = 0 ; n < map->size ; n++) {
         UcxMapElement *elem = map->map[n];
         if (elem != NULL) {
@@ -41,6 +41,10 @@
         }
     }
     free(map->map);
+}
+
+void ucx_map_free(UcxMap *map) {
+    ucx_map_free_elmlist(map);
     free(map);
 }
 
@@ -83,7 +87,9 @@
         }
         map->count = 0;
         ucx_map_copy(&oldmap, map, NULL, NULL);
-        /* TODO: free the UcxMapElement list of oldmap */
+        
+        /* free the UcxMapElement list of oldmap */
+        ucx_map_free_elmlist(&oldmap);
     }
     return 0;
 }
--- a/ucx/test.h	Fri Oct 12 10:54:55 2012 +0200
+++ b/ucx/test.h	Fri Oct 12 12:00:06 2012 +0200
@@ -61,7 +61,7 @@
 void ucx_test_register(UcxTestSuite*, UcxTest);
 void ucx_test_run(UcxTestSuite*, FILE*);
 
-#define UCX_TEST_DECLARE(name) void name(UcxTestSuite*,FILE *);
+#define UCX_TEST_DECLARE(name) void name(UcxTestSuite*,FILE *)
 #define UCX_TEST_IMPLEMENT(name) void name(UcxTestSuite* _suite_,FILE *_output_)
 
 #define UCX_TEST_BEGIN fwrite("Running ", 1, 8, _output_);\

mercurial