ucx/mempool.h

Fri, 12 Oct 2012 10:54:55 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 12 Oct 2012 10:54:55 +0200
changeset 69
fb59270b1de3
parent 50
ff194559eb41
child 103
08018864fb91
permissions
-rw-r--r--

made the code work with VC++ compiler (use make CONF=windows)

     1 /* 
     2  *
     3  */
     5 #ifndef MPOOL_H
     6 #define	MPOOL_H
     8 #include "ucx.h"
     9 #include <stddef.h>
    10 #include "allocator.h"
    12 #ifdef	__cplusplus
    13 extern "C" {
    14 #endif
    16 typedef void(*ucx_destructor)(void*);
    18 typedef struct {
    19     void   **data;
    20     size_t ndata;
    21     size_t size;
    22 } UcxMempool;
    24 #define UCX_ALLOCATOR_MEMPOOL(pool) {pool, \
    25     (ucx_allocator_malloc) ucx_mempool_malloc, \
    26     (ucx_allocator_calloc) ucx_mempool_calloc, \
    27     (ucx_allocator_realloc) ucx_mempool_realloc}
    29 #define ucx_mempool_new_default() ucx_mempool_new(16)
    30 UcxMempool *ucx_mempool_new(size_t n);
    31 int ucx_mempool_chcap(UcxMempool *pool, size_t newcap);
    33 void *ucx_mempool_malloc(UcxMempool *pool, size_t n);
    34 void *ucx_mempool_calloc(UcxMempool *pool, size_t nelem, size_t elsize);
    35 void *ucx_mempool_realloc(UcxMempool *pool, void *ptr, size_t n);
    37 void ucx_mempool_free(UcxMempool *pool);
    39 void ucx_mempool_set_destr(void *ptr, ucx_destructor func);
    40 void ucx_mempool_reg_destr(UcxMempool *pool, void *ptr, ucx_destructor destr);
    43 #ifdef	__cplusplus
    44 }
    45 #endif
    47 #endif	/* MPOOL_H */

mercurial