I have been reading "How to realloc some memory allocated using calloc?". Now I am wondering whether a realloc
followed by a calloc
will zero out new bytes if the block is larger.
Silly example:
#include <stdlib.h>
#include <string.h>
int test() {
char *mem;
mem = calloc(100, 1);
mem = realloc(mem, 120);
memset(mem + 100, 0, 20); // is this even necessary?
}
I have tested it, and it seems to be zeroed out - but I am not sure whether it is always the case?