Removing redundant copy after realloc