Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
|
Go to the source code of this file.
Functions | |
void * | realloc (void *ptr, size_t size) |
Reallocates the given area of memory. More... | |
void * | reallocf (void *ptr, size_t size) |
Reallocates the given area of memory. More... | |
void* realloc | ( | void * | ptr, |
size_t | size | ||
) |
Reallocates the given area of memory.
Reallocates the given area of memory. It must be previously allocated by
The reallocation is done by either: 1) expanding or contracting the existing area pointed to by ptr, if possible. The contents of the area remain unchanged up to the lesser of the new and old sizes. If the area is expanded, the contents of the new part of the array are undefined. 2) allocating a new memory block of size size bytes, copying memory area with size equal the lesser of the new and the old sizes, and freeing the old block.
If there is not enough memory, the old memory block is not freed and null pointer is returned. If ptr is NULL, the behavior is the same as calling malloc(size).
ptr | pointer to the memory area to be reallocated |
size | new size of the array |
size
is zero (e.g. realloc(ptr,0)
) then returns NULL Definition at line 4 of file realloc.c.
References free(), malloc(), memcpy(), and NULL.
Referenced by reallocf().
void* reallocf | ( | void * | ptr, |
size_t | size | ||
) |
Reallocates the given area of memory.
Reallocates the given area of memory. It must be previously allocated by
reallocf is a FreeBSD extension to realloc that frees the input pointer if an error occurrs
This library does not handle the BSD case where realloc(ptr,0)
frees the ptr
ptr | pointer to the memory area to be reallocated |
size | new size of the array |
size
is zero (e.g. realloc(ptr,0)
) then returns NULL Definition at line 26 of file realloc.c.