First page Back Continue Last page Summary Graphics
Realloc
void *realloc(void *ptr, size_t size);
Changes the size of the memory block pointed to by ptr to size bytes. The contents will be unchanged to the minimum of the old and new sizes; newly allocated memory will be uninitialized. Unless ptr is NULL, it must have been returned by an earlier call to malloc, calloc or realloc.
If ptr is NULL, equivalent to malloc(size);
If size is equal to zero, equivalent to free(ptr).
Returns a pointer to the newly allocated memory, which is suitable for any kind of variable and may be different from ptr, or NULL if the request fails or if size was equal to 0.
If fails the original block is left untouched - it is not freed or moved.