summaryrefslogtreecommitdiff
path: root/indra/llcommon/llmemory.h
diff options
context:
space:
mode:
authorRider Linden <none@none>2015-04-15 11:54:18 -0700
committerRider Linden <none@none>2015-04-15 11:54:18 -0700
commit109e2db131514de43a2d61da1cc4ee78dc89f858 (patch)
tree217ca4b42ee516dab39198661e2bc91514a5a8e5 /indra/llcommon/llmemory.h
parent176d8cd268611e28c07a462df3027f4872456e5a (diff)
parent82ae214f6a367e17dd335e80e2444cf672108821 (diff)
Merge
Diffstat (limited to 'indra/llcommon/llmemory.h')
-rwxr-xr-xindra/llcommon/llmemory.h54
1 files changed, 33 insertions, 21 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 7d1d541a4b..c4c9cc0566 100755
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -94,32 +94,44 @@ template <typename T> T* LL_NEXT_ALIGNED_ADDRESS_64(T* address)
#define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16)
-
-inline void* ll_aligned_malloc_fallback( size_t size, int align )
-{
-#if defined(LL_WINDOWS)
- return _aligned_malloc(size, align);
+//------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
+ // for enable buffer overrun detection predefine LL_DEBUG_BUFFER_OVERRUN in current library
+ // change preprocessro code to: #if 1 && defined(LL_WINDOWS)
+
+#if 0 && defined(LL_WINDOWS)
+ void* ll_aligned_malloc_fallback( size_t size, int align );
+ void ll_aligned_free_fallback( void* ptr );
+//------------------------------------------------------------------------------------------------
#else
- void* mem = malloc( size + (align - 1) + sizeof(void*) );
- char* aligned = ((char*)mem) + sizeof(void*);
- aligned += align - ((uintptr_t)aligned & (align - 1));
-
- ((void**)aligned)[-1] = mem;
- return aligned;
-#endif
-}
+ inline void* ll_aligned_malloc_fallback( size_t size, int align )
+ {
+ #if defined(LL_WINDOWS)
+ return _aligned_malloc(size, align);
+ #else
+ void* mem = malloc( size + (align - 1) + sizeof(void*) );
+ char* aligned = ((char*)mem) + sizeof(void*);
+ aligned += align - ((uintptr_t)aligned & (align - 1));
+
+ ((void**)aligned)[-1] = mem;
+ return aligned;
+ #endif
+ }
-inline void ll_aligned_free_fallback( void* ptr )
-{
-#if defined(LL_WINDOWS)
- _aligned_free(ptr);
-#else
- if (ptr)
+ inline void ll_aligned_free_fallback( void* ptr )
{
- free( ((void**)ptr)[-1] );
+ #if defined(LL_WINDOWS)
+ _aligned_free(ptr);
+ #else
+ if (ptr)
+ {
+ free( ((void**)ptr)[-1] );
+ }
+ #endif
}
#endif
-}
+//------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
#if !LL_USE_TCMALLOC
inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed with ll_aligned_free_16().