ucx/allocator.h

changeset 50
ff194559eb41
child 52
34f50d0bada4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ucx/allocator.h	Fri Oct 05 13:23:25 2012 +0200
     1.3 @@ -0,0 +1,32 @@
     1.4 +#ifndef ALLOCATOR_H
     1.5 +#define ALLOCATOR_H
     1.6 +
     1.7 +#include <stddef.h>
     1.8 +
     1.9 +#ifdef  __cplusplus
    1.10 +extern "C" {
    1.11 +#endif
    1.12 +
    1.13 +typedef void*(*ucx_allocator_malloc)(void *pool, size_t n);
    1.14 +typedef void*(*ucx_allocator_calloc)(void *pool, size_t n, size_t size);
    1.15 +typedef void*(*ucx_allocator_realloc)(void *pool, void *data, size_t n);
    1.16 +
    1.17 +typedef struct {
    1.18 +    void *pool;
    1.19 +    ucx_allocator_malloc malloc;
    1.20 +    ucx_allocator_calloc calloc;
    1.21 +    ucx_allocator_realloc realloc;
    1.22 +} UcxAllocator;
    1.23 +
    1.24 +void *ucx_default_malloc(void *ignore, size_t n);
    1.25 +void *ucx_default_calloc(void *ignore, size_t n, size_t size);
    1.26 +void *ucx_default_realloc(void *ignore, void *data, size_t n);
    1.27 +
    1.28 +#define UCX_ALLOCATOR_DEFAULT {NULL, \
    1.29 +    ucx_default_malloc, ucx_default_calloc, ucx_default_realloc}
    1.30 +
    1.31 +#ifdef  __cplusplus
    1.32 +}
    1.33 +#endif
    1.34 +
    1.35 +#endif /* ALLOCATOR_H */

mercurial