diff options
author | William Todd Stinson <stinson@lindenlab.com> | 2012-09-20 19:43:54 -0700 |
---|---|---|
committer | William Todd Stinson <stinson@lindenlab.com> | 2012-09-20 19:43:54 -0700 |
commit | c6a2ac0489859111276421d620abd156339c607d (patch) | |
tree | 1bfbeb5d0ddcedd77854e5e5c8b6ad675ed6ef3c /indra/llcommon | |
parent | ae127dc01ab10d407cf165ae2ad74060f65c1832 (diff) | |
parent | 29cdf94e95d0a4365bd18860c4759f9a6a13f45a (diff) |
Pull and merge from ssh://hg@bitbucket.org/stinson_linden/viewer-beta-drtvwr-179.
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llmemory.h | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 9dd776ff57..f37e8459ff 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -58,27 +58,35 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi #endif } -inline void* ll_aligned_realloc_16(void* ptr, size_t size) // returned hunk MUST be freed with ll_aligned_free_16(). +inline void ll_aligned_free_16(void *p) { #if defined(LL_WINDOWS) - return _aligned_realloc(ptr, size, 16); + _aligned_free(p); #elif defined(LL_DARWIN) - return realloc(ptr,size); // default osx malloc is 16 byte aligned. + return free(p); #else - return realloc(ptr,size); // FIXME not guaranteed to be aligned. + free(p); // posix_memalign() is compatible with heap deallocator #endif } -inline void ll_aligned_free_16(void *p) +inline void* ll_aligned_realloc_16(void* ptr, size_t size, size_t old_size) // returned hunk MUST be freed with ll_aligned_free_16(). { #if defined(LL_WINDOWS) - _aligned_free(p); + return _aligned_realloc(ptr, size, 16); #elif defined(LL_DARWIN) - return free(p); + return realloc(ptr,size); // default osx malloc is 16 byte aligned. #else - free(p); // posix_memalign() is compatible with heap deallocator + //FIXME: memcpy is SLOW + void* ret = ll_aligned_malloc_16(size); + if (ptr) + { + memcpy(ret, ptr, old_size); + ll_aligned_free_16(ptr); + } + return ret; #endif } + #else // USE_TCMALLOC // ll_aligned_foo_16 are not needed with tcmalloc #define ll_aligned_malloc_16 malloc |