BLI_Buffer: fix BLI_buffer_resize w/ calloc flag

When resizing, zero memory when the calloc flag is set,
even when no realloc is done.
This commit is contained in:
Campbell Barton 2015-10-04 13:52:13 +11:00
parent 5443d41882
commit 38f4aeb2d3
1 changed files with 8 additions and 0 deletions

View File

@ -65,6 +65,14 @@ void BLI_buffer_resize(BLI_Buffer *buffer, int new_count)
buffer->data = buffer_realloc(buffer, buffer->alloc_count);
}
}
else {
if (buffer->flag & BLI_BUFFER_USE_CALLOC) {
if (new_count > buffer->count) {
memset(POINTER_OFFSET(buffer->data, buffer->elem_size * buffer->count), 0,
buffer->elem_size * (new_count - buffer->count));
}
}
}
buffer->count = new_count;
}