xref: /freebsd/contrib/unbound/compat/malloc.c (revision 0eefd3079a04edf4cf315403beb0344724567f42)
1b7579f77SDag-Erling Smørgrav /* Just a replacement, if the original malloc is not
2b7579f77SDag-Erling Smørgrav    GNU-compliant. See autoconf documentation. */
3b7579f77SDag-Erling Smørgrav 
4b7579f77SDag-Erling Smørgrav #include "config.h"
5b7579f77SDag-Erling Smørgrav #undef malloc
6b7579f77SDag-Erling Smørgrav #include <sys/types.h>
7b7579f77SDag-Erling Smørgrav 
8*0eefd307SCy Schubert #ifndef USE_WINSOCK
9b7579f77SDag-Erling Smørgrav void *malloc ();
10*0eefd307SCy Schubert #else
11*0eefd307SCy Schubert /* provide a prototype */
12*0eefd307SCy Schubert void *malloc (size_t n);
13*0eefd307SCy Schubert #endif
14b7579f77SDag-Erling Smørgrav 
15b7579f77SDag-Erling Smørgrav /* Allocate an N-byte block of memory from the heap.
16b7579f77SDag-Erling Smørgrav    If N is zero, allocate a 1-byte block.  */
17b7579f77SDag-Erling Smørgrav 
18b7579f77SDag-Erling Smørgrav void *
rpl_malloc_unbound(size_t n)19b7579f77SDag-Erling Smørgrav rpl_malloc_unbound (size_t n)
20b7579f77SDag-Erling Smørgrav {
21b7579f77SDag-Erling Smørgrav   if (n == 0)
22b7579f77SDag-Erling Smørgrav     n = 1;
23b7579f77SDag-Erling Smørgrav   return malloc (n);
24b7579f77SDag-Erling Smørgrav }
25