summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2009-08-02 19:19:10 +0200
committerJohannes Weiner <hannes@cmpxchg.org>2009-08-02 19:19:10 +0200
commitdfee854244f18441ccf9ef80dc0a2394c4f04085 (patch)
tree6f227f42827f1a641c519f00687c5ac4b6031951
parentb27b3b763acd522a8e0b7c34356924c8bdf150a8 (diff)
util: implement sheep_free()
-rw-r--r--include/sheep/util.h1
-rw-r--r--sheep/Makefile2
-rw-r--r--sheep/map.c3
-rw-r--r--sheep/object.c3
-rw-r--r--sheep/util.c5
5 files changed, 9 insertions, 5 deletions
diff --git a/include/sheep/util.h b/include/sheep/util.h
index f4b4fe9..93ca3b1 100644
--- a/include/sheep/util.h
+++ b/include/sheep/util.h
@@ -7,5 +7,6 @@ void *sheep_malloc(size_t);
void *sheep_zalloc(size_t);
void *sheep_realloc(void *, size_t);
char *sheep_strdup(const char *);
+void sheep_free(const void *);
#endif /* _SHEEP_UTIL_H */
diff --git a/sheep/Makefile b/sheep/Makefile
index c8ce97d..f5a8fa8 100644
--- a/sheep/Makefile
+++ b/sheep/Makefile
@@ -1 +1 @@
-sheep-obj := util.o vector.o map.o object.o main.o
+sheep-obj := util.o vector.o map.o object.o name.o main.o
diff --git a/sheep/map.c b/sheep/map.c
index c6ebe7b..dc9acaa 100644
--- a/sheep/map.c
+++ b/sheep/map.c
@@ -1,5 +1,4 @@
#include <sheep/util.h>
-#include <stdlib.h>
#include <string.h>
#include <sheep/map.h>
@@ -71,6 +70,6 @@ int sheep_map_del(struct sheep_map *map, const char *name)
return -1;
entry = *pentry;
*pentry = entry->next;
- free(entry);
+ sheep_free(entry);
return 0;
}
diff --git a/sheep/object.c b/sheep/object.c
index f5e2288..ee72722 100644
--- a/sheep/object.c
+++ b/sheep/object.c
@@ -3,7 +3,6 @@
#include <sheep/vm.h>
#include <sys/mman.h>
#include <assert.h>
-#include <stdlib.h>
#include <unistd.h>
#include <sheep/object.h>
@@ -38,7 +37,7 @@ static struct sheep_objects *alloc_pool(void)
static void free_pool(struct sheep_objects *pool)
{
munmap(pool->mem, PAGE_SIZE);
- free(pool);
+ sheep_free(pool);
}
static void mark_protected(struct sheep_vector *protected)
diff --git a/sheep/util.c b/sheep/util.c
index beefe4c..3fa7b62 100644
--- a/sheep/util.c
+++ b/sheep/util.c
@@ -31,3 +31,8 @@ char *sheep_strdup(const char *str)
{
return massert(strdup(str));
}
+
+void sheep_free(const void *mem)
+{
+ free((void *)mem);
+}