Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-12-23 17:52:54 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-12-23 17:52:54 +0300
commitb9dea0f94159f4b64e65ec80314d393107d4eb28 (patch)
tree37261270086c9233fdb0c97b1765c316da5e2051
parentac782ba31cba4d5c349e97326cc7d77dfc71fd70 (diff)
Remove BLI_buffer calloc option
This wasn't working reliably (after clear for example), and wasn't used anywhere.
-rw-r--r--source/blender/blenlib/BLI_buffer.h26
-rw-r--r--source/blender/blenlib/intern/buffer.c22
2 files changed, 13 insertions, 35 deletions
diff --git a/source/blender/blenlib/BLI_buffer.h b/source/blender/blenlib/BLI_buffer.h
index 6ea9e765c1d..0c0845daf19 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 fb1b733fc8a..a54fc2428fe 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;
}