From ddb01cbb4eb8431b042918438e6543003851a87f Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 24 Feb 2004 23:08:31 +0000 Subject: [PATCH] Added mp_strdup(). --- lib/pool.c | 9 +++++++++ lib/pools.h | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/pool.c b/lib/pool.c index 8b7c3725..d581466b 100644 --- a/lib/pool.c +++ b/lib/pool.c @@ -109,3 +109,12 @@ mp_alloc_zero(struct mempool *p, uns s) bzero(x, s); return x; } + +char * +mp_strdup(struct mempool *p, char *s) +{ + uns l = strlen(s) + 1; + char *t = mp_alloc_fast_noalign(p, l); + memcpy(t, s, l); + return t; +} diff --git a/lib/pools.h b/lib/pools.h index a055ef26..ff9250dc 100644 --- a/lib/pools.h +++ b/lib/pools.h @@ -1,7 +1,7 @@ /* * Sherlock Library -- Memory Pools * - * (c) 1997--2003 Martin Mares + * (c) 1997--2004 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -26,6 +26,7 @@ void mp_delete(struct mempool *); void mp_flush(struct mempool *); void *mp_alloc(struct mempool *, uns); void *mp_alloc_zero(struct mempool *, uns); +char *mp_strdup(struct mempool *, char *); static inline void *mp_alloc_fast(struct mempool *p, uns l) { -- 2.39.2