X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fpool.c;h=d581466ba210c87b8a3cb92dea9778a9f78cf259;hb=b8a57a2068377dbc303ae97f015bd07b20051b6a;hp=6143c68af0b67c5f2f87301b08e90773e8b31000;hpb=b7e3d06a00ca5c95df8202678da7e3b11037c6be;p=libucw.git diff --git a/lib/pool.c b/lib/pool.c index 6143c68a..d581466b 100644 --- a/lib/pool.c +++ b/lib/pool.c @@ -2,12 +2,16 @@ * Sherlock Library -- Memory Pools (One-Time Allocation) * * (c) 1997--2001 Martin Mares + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ #include "lib/lib.h" #include "lib/pools.h" #include +#include struct memchunk { struct memchunk *next; @@ -97,3 +101,20 @@ mp_alloc(struct mempool *p, uns s) return c->data; } } + +void * +mp_alloc_zero(struct mempool *p, uns s) +{ + void *x = mp_alloc(p, 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; +}