diff options
author | Ton Roosendaal <ton@blender.org> | 2006-10-24 19:17:14 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-10-24 19:17:14 +0400 |
commit | 9d67a597bc2bff427c958e013d83f763386223f7 (patch) | |
tree | 30ecbfda075ac60fc6f888a70836f89bf4c43b53 /source/blender | |
parent | da12c9571b99abec0de960324a4fc7e36adc94b5 (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')
-rw-r--r-- | source/blender/blenlib/BLI_memarena.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_memarena.c | 14 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadbuf.c | 2 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 2 |
4 files changed, 17 insertions, 3 deletions
diff --git a/source/blender/blenlib/BLI_memarena.h b/source/blender/blenlib/BLI_memarena.h index 1423cae52af..420995e3b11 100644 --- a/source/blender/blenlib/BLI_memarena.h +++ b/source/blender/blenlib/BLI_memarena.h @@ -53,6 +53,8 @@ typedef struct MemArena MemArena; struct MemArena* BLI_memarena_new (int bufsize); void BLI_memarena_free (struct MemArena *ma); +void BLI_memarena_use_calloc (struct MemArena *ma); + void* BLI_memarena_alloc (struct MemArena *ma, int size); #endif 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); } diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 73889b6578a..f5a6cebd492 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -1609,6 +1609,7 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar) /* branches are added using memarena (32k branches) */ memarena = BLI_memarena_new(0x8000 * sizeof(ISBBranch)); + BLI_memarena_use_calloc(memarena); /* samplebuf is in camera view space (pixels) */ for(sample=0; sample<(R.osa?R.osa:1); sample++) @@ -1803,6 +1804,7 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la /* branches are added using memarena (32k branches) */ memarena = BLI_memarena_new(0x8000 * sizeof(ISBBranch)); + BLI_memarena_use_calloc(memarena); /* samplebuf is in camera view space (pixels) */ for(sample=0; sample<(R.osa?R.osa:1); sample++) diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index c7bfef675ee..7b0970d0cd1 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -2153,7 +2153,7 @@ static void lamp_panel_spot(Object *ob, Lamp *la) if(la->buftype==LA_SHADBUF_IRREGULAR) tip= "Irregular buffer produces sharp shadow always, but it doesn't show up for raytracing"; else if(la->buftype==LA_SHADBUF_HALFWAY) - tip= "Regular buffer, averaginng the closest and 2nd closest Z value for reducing biasing"; + tip= "Regular buffer, averaging the closest and 2nd closest Z value for reducing biasing"; uiDefButC(block, MENU, B_REDR, "Classical %x0|Classic-Halfway %x2|Irregular %x1", 10,140,80,19,&la->buftype, 0, 0, 0, 0, tip); } |