What is the best way to zero out new memory after calling realloc while keeping the initially allocated memory intact?
#include #include <
First of all, realloc can fail, so you need to check for NULL. Second, there is no better way to zero out the memory: just memset from the end of the old buffer to the end of the larger buffer.