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:
authorTon Roosendaal <ton@blender.org>2006-10-24 19:17:14 +0400
committerTon Roosendaal <ton@blender.org>2006-10-24 19:17:14 +0400
commit9d67a597bc2bff427c958e013d83f763386223f7 (patch)
tree30ecbfda075ac60fc6f888a70836f89bf4c43b53 /source/blender/blenlib/intern/BLI_memarena.c
parentda12c9571b99abec0de960324a4fc7e36adc94b5 (diff)
Irregular shadow fix: the MemArena module didn't give callocs, only malloc.
Made nice crashes that way... but not in !@%@$ OSX because it seems to clear memory unwanted. Solve dit with adding API call in MemArena to default to callocs. Also removed malloc() from MemArena, replaced with MEM_mallocN().
Diffstat (limited to 'source/blender/blenlib/intern/BLI_memarena.c')
-rw-r--r--source/blender/blenlib/intern/BLI_memarena.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c
index f81cbfbe6c4..c42ff3610fd 100644
--- a/source/blender/blenlib/intern/BLI_memarena.c
+++ b/source/blender/blenlib/intern/BLI_memarena.c
@@ -47,6 +47,8 @@ struct MemArena {
unsigned char *curbuf;
int bufsize, cursize;
+ int use_calloc;
+
LinkNode *bufs;
};
@@ -56,8 +58,13 @@ MemArena *BLI_memarena_new(int bufsize) {
return ma;
}
+
+void BLI_memarena_use_calloc(MemArena *ma) {
+ ma->use_calloc= 1;
+}
+
void BLI_memarena_free(MemArena *ma) {
- BLI_linklist_free(ma->bufs, (void(*)(void*)) free);
+ BLI_linklist_free(ma->bufs, (void(*)(void*)) MEM_freeN);
MEM_freeN(ma);
}
@@ -73,7 +80,10 @@ void *BLI_memarena_alloc(MemArena *ma, int size) {
if (size>ma->cursize) {
ma->cursize= (size>ma->bufsize)?size:ma->bufsize;
- ma->curbuf= malloc(ma->cursize);
+ if(ma->use_calloc)
+ ma->curbuf= MEM_callocN(ma->cursize, "memarena calloc");
+ else
+ ma->curbuf= MEM_mallocN(ma->cursize, "memarena malloc");
BLI_linklist_prepend(&ma->bufs, ma->curbuf);
}