X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fpool.c;h=4eea7bf700f8e0ab0981bd22c0f2b3933050f546;hb=995458e48d482bd5fa349882fba5cb4d6350076d;hp=b4783e87c46bb7a24fbbd76faf4bf79c321adb08;hpb=76ee03dea8ff0a04d7659ded5a9a53ef3eb39aa7;p=libucw.git diff --git a/lib/pool.c b/lib/pool.c index b4783e87..4eea7bf7 100644 --- a/lib/pool.c +++ b/lib/pool.c @@ -1,13 +1,14 @@ /* * Sherlock Library -- Memory Pools (One-Time Allocation) * - * (c) 1997--1999 Martin Mares + * (c) 1997--2001 Martin Mares */ #include "lib/lib.h" #include "lib/pools.h" #include +#include struct memchunk { struct memchunk *next; @@ -15,7 +16,7 @@ struct memchunk { }; struct mempool * -new_pool(uns size) +mp_new(uns size) { struct mempool *p = xmalloc(sizeof(struct mempool)); @@ -29,7 +30,7 @@ new_pool(uns size) } void -free_pool(struct mempool *p) +mp_delete(struct mempool *p) { struct memchunk *c, *d; @@ -47,7 +48,7 @@ free_pool(struct mempool *p) } void -flush_pool(struct mempool *p) +mp_flush(struct mempool *p) { struct memchunk *c; @@ -61,7 +62,7 @@ flush_pool(struct mempool *p) } void * -pool_alloc(struct mempool *p, uns s) +mp_alloc(struct mempool *p, uns s) { if (s <= p->threshold) { @@ -97,3 +98,11 @@ pool_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; +}