[Bf-blender-cvs] [b9dea0f] master: Remove BLI_buffer calloc option

Campbell Barton noreply at git.blender.org
Wed Dec 23 16:01:04 CET 2015


Commit: b9dea0f94159f4b64e65ec80314d393107d4eb28
Author: Campbell Barton
Date:   Thu Dec 24 01:52:54 2015 +1100
Branches: master
https://developer.blender.org/rBb9dea0f94159f4b64e65ec80314d393107d4eb28

Remove BLI_buffer calloc option

This wasn't working reliably (after clear for example), and wasn't used anywhere.

===================================================================

M	source/blender/blenlib/BLI_buffer.h
M	source/blender/blenlib/intern/buffer.c

===================================================================

diff --git a/source/blender/blenlib/BLI_buffer.h b/source/blender/blenlib/BLI_buffer.h
index 6ea9e76..0c0845d 100644
--- a/source/blender/blenlib/BLI_buffer.h
+++ b/source/blender/blenlib/BLI_buffer.h
@@ -35,31 +35,27 @@ typedef struct {
 enum {
 	BLI_BUFFER_NOP        = 0,
 	BLI_BUFFER_USE_STATIC = (1 << 0),
-	BLI_BUFFER_USE_CALLOC = (1 << 1),  /* ensure the array is always calloc'd */
 };
 
 #define BLI_buffer_declare_static(type_, name_, flag_, static_count_) \
 	char name_ ## user;  /* warn for free only */ \
 	type_ name_ ## _static_[static_count_]; \
 	BLI_Buffer name_ = { \
-	/* clear the static memory if this is a calloc'd array */ \
-	((void)((flag_ & BLI_BUFFER_USE_CALLOC) ? \
-	          memset(name_ ## _static_, 0, sizeof(name_ ## _static_)) : NULL \
-	), /* memset-end */ \
-	                    name_ ## _static_), \
-	                    sizeof(type_), \
-	                    0, \
-	                    static_count_, \
-	                    BLI_BUFFER_USE_STATIC | flag_}
+	        (name_ ## _static_), \
+	        sizeof(type_), \
+	        0, \
+	        static_count_, \
+	        BLI_BUFFER_USE_STATIC | (flag_)}
 
 /* never use static*/
 #define BLI_buffer_declare(type_, name_, flag_) \
 	bool name_ ## user;  /* warn for free only */ \
-	BLI_Buffer name_ = {NULL, \
-	                    sizeof(type_), \
-	                    0, \
-	                    0, \
-	                    flag_}
+	BLI_Buffer name_ = { \
+	        NULL, \
+	        sizeof(type_), \
+	        0, \
+	        0, \
+	        (flag_)}
 
 #define BLI_buffer_at(buffer_, type_, index_) ( \
 	(((type_ *)(buffer_)->data)[ \
diff --git a/source/blender/blenlib/intern/buffer.c b/source/blender/blenlib/intern/buffer.c
index fb1b733..a54fc24 100644
--- a/source/blender/blenlib/intern/buffer.c
+++ b/source/blender/blenlib/intern/buffer.c
@@ -56,16 +56,12 @@
 
 static void *buffer_alloc(BLI_Buffer *buffer, const size_t len)
 {
-	return ((buffer->flag & BLI_BUFFER_USE_CALLOC) ?
-	        MEM_callocN : MEM_mallocN)
-	        (buffer->elem_size * len, "BLI_Buffer.data");
+	return MEM_mallocN(buffer->elem_size * len, "BLI_Buffer.data");
 }
 
 static void *buffer_realloc(BLI_Buffer *buffer, const size_t len)
 {
-	return ((buffer->flag & BLI_BUFFER_USE_CALLOC) ?
-	        MEM_recallocN_id : MEM_reallocN_id)
-	        (buffer->data, buffer->elem_size * len, "BLI_Buffer.data");
+	return MEM_reallocN_id(buffer->data, buffer->elem_size * len, "BLI_Buffer.data");
 }
 
 void BLI_buffer_resize(BLI_Buffer *buffer, const size_t new_count)
@@ -90,14 +86,6 @@ void BLI_buffer_resize(BLI_Buffer *buffer, const size_t 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;
 }
@@ -126,12 +114,6 @@ void BLI_buffer_reinit(BLI_Buffer *buffer, const size_t new_count)
 		buffer->flag &= ~BLI_BUFFER_USE_STATIC;
 		buffer->data = buffer_alloc(buffer, buffer->alloc_count);
 	}
-	else {
-		if (buffer->flag & BLI_BUFFER_USE_CALLOC) {
-			memset(buffer->data, 0,
-			       buffer->elem_size * new_count);
-		}
-	}
 
 	buffer->count = new_count;
 }




More information about the Bf-blender-cvs mailing list