1REALLOCF(3bsd)                       LOCAL                      REALLOCF(3bsd)
2

NAME

4     reallocf — general purpose memory allocation functions
5

LIBRARY

7     Utility functions from BSD systems (libbsd, -lbsd)
8

SYNOPSIS

10     #include <stdlib.h>
11     (See libbsd(7) for include usage.)
12
13     void *
14     reallocf(void *ptr, size_t size);
15

DESCRIPTION

17     The reallocf() function changes the size of the previously allocated mem‐
18     ory referenced by ptr to size bytes.  The contents of the memory are
19     unchanged up to the lesser of the new and old sizes.  If the new size is
20     larger, the contents of the newly allocated portion of the memory are
21     undefined.  Upon success, the memory referenced by ptr is freed and a
22     pointer to the newly allocated memory is returned.  Note that reallocf()
23     may move the memory allocation, resulting in a different return value
24     than ptr.  If ptr is NULL, the reallocf() function behaves identically to
25     malloc() for the specified size.  Upon failure, when the requested memory
26     cannot be allocated, the passed pointer is freed to ease the problems
27     with traditional coding styles for reallocf() causing memory leaks in
28     libraries.
29

RETURN VALUES

31     The reallocf() function returns a pointer, possibly identical to ptr, to
32     the allocated memory if successful; otherwise a NULL pointer is returned,
33     and errno is set to ENOMEM if the error was the result of an allocation
34     failure.  The buffer is deallocated in this case.
35

SEE ALSO

37     brk(2), mmap(2), alloca(3), calloc(3), free(3), malloc(3),
38     posix_memalign(3), realloc(3),
39

HISTORY

41     The reallocf() function first appeared in FreeBSD 3.0.
42
43BSD                           September 26, 2009                           BSD
Impressum