From bb09c40e2f9dcca5a1dbf55f5bbc572d8b7bfb9d Mon Sep 17 00:00:00 2001 From: Not Zed Date: Tue, 21 Nov 2000 14:31:41 +0000 Subject: New function to strdup into a mempool. 2000-11-21 Not Zed * e-memory.c (e_mempool_strdup): New function to strdup into a mempool. svn path=/trunk/; revision=6630 --- e-util/ChangeLog | 1 + e-util/e-memory.c | 10 ++++++++++ e-util/e-memory.h | 1 + 3 files changed, 12 insertions(+) diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 2fbb4631a2..d370ef880e 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -2,6 +2,7 @@ * e-memory.c (e_memchunk_alloc0): New function to allocate a zero'd out chunk. + (e_mempool_strdup): New function to strdup into a mempool. 2000-11-20 Not Zed diff --git a/e-util/e-memory.c b/e-util/e-memory.c index 2a3cd55771..37ec181ce9 100644 --- a/e-util/e-memory.c +++ b/e-util/e-memory.c @@ -427,6 +427,16 @@ void *e_mempool_alloc(MemPool *pool, int size) } } +char *e_mempool_strdup(EMemPool *pool, const char *str) +{ + char *out; + + out = e_mempool_alloc(pool, strlen(str)); + strcpy(out, str); + + return out; +} + /** * e_mempool_flush: * @pool: diff --git a/e-util/e-memory.h b/e-util/e-memory.h index 3f1f2f0f4d..378c485530 100644 --- a/e-util/e-memory.h +++ b/e-util/e-memory.h @@ -46,6 +46,7 @@ typedef enum { EMemPool *e_mempool_new(int blocksize, int threshold, EMemPoolFlags flags); void *e_mempool_alloc(EMemPool *pool, int size); +char *e_mempool_strdup(EMemPool *pool, const char *str); void e_mempool_flush(EMemPool *pool, int freeall); void e_mempool_destroy(EMemPool *pool); -- cgit