aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-03-29 03:04:55 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-03-29 03:04:55 +0200
commit8c6d18757d2d4135963f3dbab6d2d5ec8c8b6af3 (patch)
tree5660f32bab4bc752da50b51130a1659c2b15860f
parentf20218e73ecae27f9e9f9bf34e9798080de6f93d (diff)
downloadliberty-8c6d18757d2d4135963f3dbab6d2d5ec8c8b6af3.tar.gz
liberty-8c6d18757d2d4135963f3dbab6d2d5ec8c8b6af3.tar.xz
liberty-8c6d18757d2d4135963f3dbab6d2d5ec8c8b6af3.zip
Factor out str_map_clear()
-rw-r--r--liberty.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/liberty.c b/liberty.c
index a46bc0d..da1e926 100644
--- a/liberty.c
+++ b/liberty.c
@@ -689,7 +689,7 @@ str_map_init (struct str_map *self)
}
static void
-str_map_free (struct str_map *self)
+str_map_clear (struct str_map *self)
{
struct str_map_link **iter, **end = self->map + self->alloc;
struct str_map_link *link, *tmp;
@@ -703,6 +703,14 @@ str_map_free (struct str_map *self)
free (link);
}
+ self->len = 0;
+ memset (self->map, 0, self->alloc * sizeof *self->map);
+}
+
+static void
+str_map_free (struct str_map *self)
+{
+ str_map_clear (self);
free (self->map);
self->map = NULL;
}