X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fmempool.h;h=95727688ac9b8be0302d0fae414ce04b984569a9;hb=ccc6aa0a17952f8dacc0edd60de8e5aa11e2df60;hp=6058c5eefc9549de214660e3df2c7eea22805fb6;hpb=2771551e0dbfc9517ca6fd68f0db362434ceddbb;p=libucw.git diff --git a/lib/mempool.h b/lib/mempool.h index 6058c5ee..95727688 100644 --- a/lib/mempool.h +++ b/lib/mempool.h @@ -1,14 +1,14 @@ /* - * Sherlock Library -- Memory Pools + * UCW Library -- Memory Pools * - * (c) 1997--2004 Martin Mares + * (c) 1997--2005 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. */ -#ifndef _SHERLOCK_POOLS_H -#define _SHERLOCK_POOLS_H +#ifndef _UCW_POOLS_H +#define _UCW_POOLS_H #ifndef POOL_ALIGN #define POOL_ALIGN CPU_STRUCT_ALIGN @@ -29,7 +29,7 @@ void *mp_alloc_zero(struct mempool *, uns); static inline void *mp_alloc_fast(struct mempool *p, uns l) { - byte *f = (void *) (((uns) p->free + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1)); + byte *f = (void *) (((addr_int_t) p->free + POOL_ALIGN - 1) & ~(addr_int_t)(POOL_ALIGN - 1)); byte *ee = f + l; if (ee > p->last) return mp_alloc(p, l); @@ -60,9 +60,10 @@ mp_end_string(struct mempool *p, void *stop) p->free = stop; } -/* pool-str.c */ +/* mempool-str.c */ char *mp_strdup(struct mempool *, char *); +void *mp_memdup(struct mempool *, void *, uns); char *mp_multicat(struct mempool *, ...); static inline char * mp_strcat(struct mempool *mp, char *x, char *y) @@ -70,4 +71,9 @@ mp_strcat(struct mempool *mp, char *x, char *y) return mp_multicat(mp, x, y, NULL); } +/* mempool-fmt.c */ + +char *mp_printf(struct mempool *p, char *fmt, ...) FORMAT_CHECK(printf,2,3); +char *mp_vprintf(struct mempool *p, char *fmt, va_list args); + #endif