[Bf-blender-cvs] [9149a28] dyntopo_holes: BLI_buffer: simplify buffer resize
Campbell Barton
noreply at git.blender.org
Sun Oct 5 14:54:21 CEST 2014
Commit: 9149a281ca3f1b8cb127bf933a50671476685dea
Author: Campbell Barton
Date: Sun Oct 5 10:31:47 2014 +0200
Branches: dyntopo_holes
https://developer.blender.org/rB9149a281ca3f1b8cb127bf933a50671476685dea
BLI_buffer: simplify buffer resize
===================================================================
M source/blender/blenlib/intern/buffer.c
===================================================================
diff --git a/source/blender/blenlib/intern/buffer.c b/source/blender/blenlib/intern/buffer.c
index 4e57082..9e96205 100644
--- a/source/blender/blenlib/intern/buffer.c
+++ b/source/blender/blenlib/intern/buffer.c
@@ -38,17 +38,14 @@ static void *buffer_alloc(BLI_Buffer *buffer, int len)
static void *buffer_realloc(BLI_Buffer *buffer, int len)
{
- if (buffer->flag & BLI_BUFFER_USE_CALLOC) {
- return MEM_recallocN(buffer->data, buffer->elem_size * len);
- }
- else {
- return MEM_reallocN(buffer->data, buffer->elem_size * len);
- }
+ return ((buffer->flag & BLI_BUFFER_USE_CALLOC) ?
+ MEM_recallocN_id : MEM_reallocN_id)
+ (buffer->data, buffer->elem_size * len, "BLI_Buffer.data");
}
void BLI_buffer_resize(BLI_Buffer *buffer, int new_count)
{
- if (new_count > buffer->alloc_count) {
+ if (UNLIKELY(new_count > buffer->alloc_count)) {
if (buffer->flag & BLI_BUFFER_USE_STATIC) {
void *orig = buffer->data;
@@ -65,12 +62,7 @@ void BLI_buffer_resize(BLI_Buffer *buffer, int new_count)
buffer->alloc_count = new_count;
}
- if (buffer->data) {
- buffer->data = buffer_realloc(buffer, buffer->alloc_count);
- }
- else {
- buffer->data = buffer_alloc(buffer, buffer->alloc_count);
- }
+ buffer->data = buffer_realloc(buffer, buffer->alloc_count);
}
}
More information about the Bf-blender-cvs
mailing list