summaryrefslogtreecommitdiffstats
path: root/moon-abe/pbc-0.5.14/include/pbc_memory.h
blob: 4c71a2e0e1f6eac29f96d776f9c81e19b2260078 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Requires:
// * stdlib.h
#ifndef __PBC_MEMORY_H__
#define __PBC_MEMORY_H__

// Memory allocation functions used by PBC.
extern void *(*pbc_malloc)(size_t);
extern void *(*pbc_realloc)(void *, size_t);
extern void (*pbc_free)(void *);

void *pbc_calloc(size_t, size_t);

/*@manual alloc
Set custom allocation functions.  The parameters must be function pointers to
drop-in replacements for malloc, realloc and free, except that malloc and
realloc should terminate the program on failure: they must not return in this
case.
*/
void pbc_set_memory_functions(void *(*malloc_fn)(size_t),
        void *(*realloc_fn)(void *, size_t), void (*free_fn)(void *));

char *pbc_strdup(const char *s);

#endif //__PBC_MEMORY_H__