src/server/ucx/mempool.h

Mon, 23 Jul 2012 15:13:19 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 23 Jul 2012 15:13:19 +0200
changeset 32
ebba53de8b18
parent 15
cff9c4101dd7
child 36
450d2d5f4735
permissions
-rw-r--r--

added solaris 10 support

/* 
 *
 */

#ifndef MPOOL_H
#define	MPOOL_H

#ifdef	__cplusplus
extern "C" {
#endif

typedef void(*ucx_destructor)(void*);

typedef struct {
    void   **data;
    size_t ndata;
    size_t size;
} UcxMempool;

#define ucx_mempool_new_default() ucx_mempool_new(16)
UcxMempool *ucx_mempool_new(size_t n);
int ucx_mempool_chcap(UcxMempool *pool, size_t newcap);

void *ucx_mempool_malloc(UcxMempool *pool, size_t n);
void *ucx_mempool_calloc(UcxMempool *pool, size_t nelem, size_t elsize);
void *ucx_mempool_realloc(UcxMempool *pool, void *ptr, size_t n);

void ucx_mempool_free(UcxMempool *pool);

void ucx_mempool_set_destr(void *ptr, ucx_destructor func);
void ucx_mempool_reg_destr(UcxMempool *pool, void *ptr, ucx_destructor destr);


#ifdef	__cplusplus
}
#endif

#endif	/* MPOOL_H */

mercurial