diff --git a/lib/mm/pool-debug.c b/lib/mm/pool-debug.c index 9065346ca..dad81af7b 100644 --- a/lib/mm/pool-debug.c +++ b/lib/mm/pool-debug.c @@ -195,25 +195,3 @@ void pool_abandon_object(struct pool *p) p->begun = 0; p->object = NULL; } - -char *pool_strdup(struct pool *p, const char *str) -{ - char *ret = pool_alloc(p, strlen(str) + 1); - - if (ret) - strcpy(ret, str); - - return ret; -} - -char *pool_strndup(struct pool *p, const char *str, size_t n) -{ - char *ret = pool_alloc(p, n + 1); - - if (ret) { - strncpy(ret, str, n); - ret[n] = '\0'; - } - - return ret; -} diff --git a/lib/mm/pool-fast.c b/lib/mm/pool-fast.c index 9d40e9391..c2f26e0eb 100644 --- a/lib/mm/pool-fast.c +++ b/lib/mm/pool-fast.c @@ -195,28 +195,6 @@ void pool_abandon_object(struct pool *p) p->object_alignment = DEFAULT_ALIGNMENT; } -char *pool_strdup(struct pool *p, const char *str) -{ - char *ret = pool_alloc(p, strlen(str) + 1); - - if (ret) - strcpy(ret, str); - - return ret; -} - -char *pool_strndup(struct pool *p, const char *str, size_t n) -{ - char *ret = pool_alloc(p, n + 1); - - if (ret) { - strncpy(ret, str, n); - ret[n] = '\0'; - } - - return ret; -} - void _align_chunk(struct chunk *c, unsigned alignment) { c->begin += alignment - ((unsigned long) c->begin & (alignment - 1)); diff --git a/lib/mm/pool.c b/lib/mm/pool.c index 2cbad670d..bbb77dcc8 100644 --- a/lib/mm/pool.c +++ b/lib/mm/pool.c @@ -9,3 +9,35 @@ #else #include "pool-fast.c" #endif + +char *pool_strdup(struct pool *p, const char *str) +{ + char *ret = pool_alloc(p, strlen(str) + 1); + + if (ret) + strcpy(ret, str); + + return ret; +} + +char *pool_strndup(struct pool *p, const char *str, size_t n) +{ + char *ret = pool_alloc(p, n + 1); + + if (ret) { + strncpy(ret, str, n); + ret[n] = '\0'; + } + + return ret; +} + +void *pool_zalloc(struct pool *p, size_t s) +{ + void *ptr = pool_alloc(p, s); + + if (ptr) + memset(ptr, 0, s); + + return ptr; +} diff --git a/lib/mm/pool.h b/lib/mm/pool.h index 4e82617dc..f3806569e 100644 --- a/lib/mm/pool.h +++ b/lib/mm/pool.h @@ -107,15 +107,6 @@ void pool_abandon_object(struct pool *p); /* utilities */ char *pool_strdup(struct pool *p, const char *str); char *pool_strndup(struct pool *p, const char *str, size_t n); - -static inline void *pool_zalloc(struct pool *p, size_t s) -{ - void *ptr = pool_alloc(p, s); - - if (ptr) - memset(ptr, 0, s); - - return ptr; -} +void *pool_zalloc(struct pool *p, size_t s); #endif