diff options
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r-- | intern/guardedalloc/MEM_guardedalloc.h | 44 | ||||
-rw-r--r-- | intern/guardedalloc/Makefile | 15 | ||||
-rw-r--r-- | intern/guardedalloc/SConscript | 2 |
3 files changed, 52 insertions, 9 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index 1d4c753802b..6cead013895 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -74,7 +74,11 @@ extern "C" { * Release memory previously allocatred by this module. */ short MEM_freeN(void *vmemh); - + short WMEM_freeN(void *vmemh); + + short _MEM_freeN(void *vmemh, char *file, int line); + #define MEM_freeN(vmemh) _MEM_freeN(vmemh, __FILE__, __LINE__) + /** * Duplicates a block of memory, and returns a pointer to the * newly allocated block. */ @@ -130,6 +134,44 @@ extern "C" { uintptr_t MEM_get_mapped_memory_in_use(void); int MEM_get_memory_blocks_in_use(void); +/********* Internal structs. They're only here for the MEM_OVERHEAD macro.*********/ + +/* --------------------------------------------------------------------- */ +/* Data definition */ +/* --------------------------------------------------------------------- */ +/* all memory chunks are put in linked lists */ +typedef struct localLink +{ + struct localLink *next,*prev; +} localLink; + +typedef struct localListBase +{ + void *first, *last; +} localListBase; + + /* note: keep this struct aligned (e.g., irix/gcc) - Hos */ +typedef struct MemHead { + int tag1; + int len; + struct MemHead *next,*prev; + const char * name; + const char * nextname; + int tag2; + int mmap; /* if true, memory was mmapped */ +} MemHead; + +typedef struct MemTail { + int tag3, pad; +} MemTail; + +/*memory bias to hopefully account + for allocation overhead from + the system allocator.*/ +#define MEM_OVERHEADBIAS 32 + +#define MEM_OVERHEAD (sizeof(MemHead) + sizeof(MemTail) + MEM_OVERHEADBIAS) + #ifdef __cplusplus } #endif diff --git a/intern/guardedalloc/Makefile b/intern/guardedalloc/Makefile index 55894d54c8e..f0cef3d222c 100644 --- a/intern/guardedalloc/Makefile +++ b/intern/guardedalloc/Makefile @@ -1,5 +1,3 @@ -# -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*- -# vim: tabstop=8 # # $Id$ # @@ -24,7 +22,7 @@ # # The Original Code is: all of this file. # -# Contributor(s): Hans Lambermont, GSR +# Contributor(s): Hans Lambermont # # ***** END GPL LICENSE BLOCK ***** # decimation main makefile. @@ -40,13 +38,16 @@ TESTDIRS = test include nan_subdirs.mk -install: $(ALL_OR_DEBUG) +install: all debug @[ -d $(NAN_GUARDEDALLOC) ] || mkdir $(NAN_GUARDEDALLOC) @[ -d $(NAN_GUARDEDALLOC)/include ] || mkdir $(NAN_GUARDEDALLOC)/include - @[ -d $(NAN_GUARDEDALLOC)/lib/$(DEBUG_DIR) ] || mkdir $(NAN_GUARDEDALLOC)/lib/$(DEBUG_DIR) - @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libguardedalloc.a $(NAN_GUARDEDALLOC)/lib/$(DEBUG_DIR) + @[ -d $(NAN_GUARDEDALLOC)/lib ] || mkdir $(NAN_GUARDEDALLOC)/lib + @[ -d $(NAN_GUARDEDALLOC)/lib/debug ] || mkdir $(NAN_GUARDEDALLOC)/lib/debug + @../tools/cpifdiff.sh $(DIR)/libguardedalloc.a $(NAN_GUARDEDALLOC)/lib/ + @../tools/cpifdiff.sh $(DIR)/debug/libguardedalloc.a $(NAN_GUARDEDALLOC)/lib/debug/ ifeq ($(OS),darwin) - ranlib $(NAN_GUARDEDALLOC)/lib/$(DEBUG_DIR)libguardedalloc.a + ranlib $(NAN_GUARDEDALLOC)/lib/libguardedalloc.a + ranlib $(NAN_GUARDEDALLOC)/lib/debug/libguardedalloc.a endif @../tools/cpifdiff.sh *.h $(NAN_GUARDEDALLOC)/include/ diff --git a/intern/guardedalloc/SConscript b/intern/guardedalloc/SConscript index 0184ddd9785..ef6c6b49266 100644 --- a/intern/guardedalloc/SConscript +++ b/intern/guardedalloc/SConscript @@ -5,4 +5,4 @@ Import('env') sources = env.Glob('intern/*.c') incs = '.' -env.BlenderLib ('bf_guardedalloc', sources, Split(incs), defines=[], libtype=['intern', 'player'], priority = [5, 175] ) +env.BlenderLib ('bf_guardedalloc', sources, Split(incs), defines=[], libtype=['intern', 'player'], priority = [10, 175] ) |