X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fmempool.h;h=350054e3fc481d0eb8a8879daabb1c1d021f7178;hb=5959916922193dea72ec0f74fa0a5211ca68f9c4;hp=7ac7f1667acef3a503a41c0661d2f73972402445;hpb=8124b0bb3dde5817810e4924eb23e907391d408d;p=libucw.git diff --git a/ucw/mempool.h b/ucw/mempool.h index 7ac7f166..350054e3 100644 --- a/ucw/mempool.h +++ b/ucw/mempool.h @@ -54,6 +54,8 @@ struct mempool_stats { /** Mempool statistics. See @mp_stats(). **/ * @chunk_size must be in the interval `[1, UINT_MAX / 2]`. * It will allocate memory by this large chunks and take * memory to satisfy requests from them. + * + * Memory pools can be treated as <>, see <>. **/ void mp_init(struct mempool *pool, uns chunk_size); @@ -62,6 +64,8 @@ void mp_init(struct mempool *pool, uns chunk_size); * See @mp_init() for @chunk_size limitations. * * The new mempool structure is allocated on the new mempool. + * + * Memory pools can be treated as <>, see <>. **/ struct mempool *mp_new(uns chunk_size); @@ -336,7 +340,7 @@ static inline void *mp_realloc_fast(struct mempool *pool, void *ptr, uns size) /** * Save the current state of a memory pool. - * Do not call this function with an opened growing buffer. + * Do not call this function with an opened growing buffer. **/ static inline void mp_save(struct mempool *pool, struct mempool_state *state) { @@ -384,7 +388,7 @@ void mp_pop(struct mempool *pool); * ----------------- ***/ -char *mp_strdup(struct mempool *, const char *) LIKE_MALLOC; /** Makes a copy of a string on a mempool. **/ +char *mp_strdup(struct mempool *, const char *) LIKE_MALLOC; /** Makes a copy of a string on a mempool. Returns NULL for NULL string. **/ void *mp_memdup(struct mempool *, const void *, uns) LIKE_MALLOC; /** Makes a copy of a memory block on a mempool. **/ /** * Concatenates all passed strings. The last parameter must be NULL. @@ -406,6 +410,11 @@ static inline char *LIKE_MALLOC mp_strcat(struct mempool *mp, const char *x, con * tells how many there is of them. **/ char *mp_strjoin(struct mempool *p, char **a, uns n, uns sep) LIKE_MALLOC; +/** + * Convert memory block to a string. Makes a copy of the given memory block + * in the mempool @p, adding an extra terminating zero byte at the end. + **/ +char *mp_str_from_mem(struct mempool *p, const void *mem, uns len) LIKE_MALLOC; /***