Consider the following code snippet:
void *ptr, *newptr;ptr = calloc(100, sizeof(char)); // error checking code not shown herenewptr = realloc(NULL, 150);
The pointer passed to realloc is NULL? The library treats this as equivalent to a new allocation – malloc(150); and all the implications of the malloc(3) That's it.
Now, consider the following code snippet:
void *ptr, *newptr;ptr = calloc(100, sizeof(char)); // error checking code not shown herenewptr = realloc(ptr, 0);
The size parameter passed to realloc is 0? The library treats this as equivalent to free(ptr). That's it.