Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/ldns/compat/realloc.c
39483 views
1
/* Just a replacement, if the original malloc is not
2
GNU-compliant. Based on malloc.c */
3
4
#if HAVE_CONFIG_H
5
#include <ldns/config.h>
6
#endif
7
#undef realloc
8
9
#include <sys/types.h>
10
11
void *realloc (void*, size_t);
12
void *malloc (size_t);
13
14
/* Changes allocation to new sizes, copies over old data.
15
* if oldptr is NULL, does a malloc.
16
* if size is zero, allocate 1-byte block....
17
* (does not return NULL and free block)
18
*/
19
20
void *
21
rpl_realloc (void* ptr, size_t n)
22
{
23
if (n == 0)
24
n = 1;
25
if(ptr == 0) {
26
return malloc(n);
27
}
28
return realloc(ptr, n);
29
}
30
31
32