Thursday, January 28, 2010

Realloc to Malloc and Realloc to Free

realloc:
void * realloc ( void * ptr, size_t size );
Reallocate memory block

In case that ptr is NULL, the function behaves exactly as MALLOC, assigning a new block of size bytes and returning a pointer to the beginning of it.

eg. realloc (NULL, sizeof(int));

In case that the size is 0, the memory previously allocated in ptr is deallocated as if a call to free was made, and a NULL pointer is returned.

No comments:

Post a Comment