fix realloc behavior