[Bf-blender-cvs] [38f4aeb] master: BLI_Buffer: fix BLI_buffer_resize w/ calloc flag
Campbell Barton
noreply at git.blender.org
Sun Oct 4 05:17:16 CEST 2015
Commit: 38f4aeb2d3da02e78307937add8f55ffc4b17845
Author: Campbell Barton
Date: Sun Oct 4 13:52:13 2015 +1100
Branches: master
https://developer.blender.org/rB38f4aeb2d3da02e78307937add8f55ffc4b17845
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.
===================================================================
M source/blender/blenlib/intern/buffer.c
===================================================================
diff --git a/source/blender/blenlib/intern/buffer.c b/source/blender/blenlib/intern/buffer.c
index 9e96205..ed47efd 100644
--- a/source/blender/blenlib/intern/buffer.c
+++ b/source/blender/blenlib/intern/buffer.c
@@ -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;
}
More information about the Bf-blender-cvs
mailing list