Permalink
Browse files

Implement map_free() properly

  • Loading branch information...
1 parent 8ba7d0a commit e108d334e882e129bf87eb4ad7db1fd589b6ff3d @b4winckler committed Feb 20, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/map_lib.c
View
@@ -51,8 +51,14 @@ map_t map_create()
void map_free(map_t m)
{
- if (m)
- free(m);
+ map_t map = m;
+ while (map) {
+ if (map->name) free(map->name);
+ if (map->value) free(map->value);
+ map_t tofree = map;
+ map = map->nxt;
+ free(tofree);
+ }
}
void map_set(map_t m, const char *key, const char *value)

0 comments on commit e108d33

Please sign in to comment.