File: realloc.c

package info (click to toggle)
ldns 1.6.17-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,688 kB
  • ctags: 5,687
  • sloc: ansic: 41,537; sh: 10,787; python: 7,671; pascal: 2,351; perl: 2,150; makefile: 1,447; xml: 518
file content (30 lines) | stat: -rw-r--r-- 567 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Just a replacement, if the original malloc is not
   GNU-compliant. Based on malloc.c */

#if HAVE_CONFIG_H
#include <ldns/config.h>
#endif
#undef realloc

#include <sys/types.h>

void *realloc (void*, size_t);
void *malloc (size_t);

/* Changes allocation to new sizes, copies over old data.
 * if oldptr is NULL, does a malloc.
 * if size is zero, allocate 1-byte block....
 *   (does not return NULL and free block)
 */

void *
rpl_realloc (void* ptr, size_t n)
{
  if (n == 0)
    n = 1;
  if(ptr == 0) {
    return malloc(n);
  }
  return realloc(ptr, n);
}