1 // Requires:
2 // * stdlib.h
3 #ifndef __PBC_MEMORY_H__
4 #define __PBC_MEMORY_H__
5 
6 // Memory allocation functions used by PBC.
7 extern void *(*pbc_malloc)(size_t);
8 extern void *(*pbc_realloc)(void *, size_t);
9 extern void (*pbc_free)(void *);
10 
11 void *pbc_calloc(size_t, size_t);
12 
13 /*@manual alloc
14 Set custom allocation functions.  The parameters must be function pointers to
15 drop-in replacements for malloc, realloc and free, except that malloc and
16 realloc should terminate the program on failure: they must not return in this
17 case.
18 */
19 void pbc_set_memory_functions(void *(*malloc_fn)(size_t),
20         void *(*realloc_fn)(void *, size_t), void (*free_fn)(void *));
21 
22 char *pbc_strdup(const char *s);
23 
24 #endif //__PBC_MEMORY_H__
25