summaryrefslogtreecommitdiff
path: root/indra/llcommon/llmemory.h
diff options
context:
space:
mode:
authorsimon@Simon-PC.lindenlab.com <simon@Simon-PC.lindenlab.com>2012-09-07 14:06:43 -0700
committersimon@Simon-PC.lindenlab.com <simon@Simon-PC.lindenlab.com>2012-09-07 14:06:43 -0700
commit4d0d3ccf60839772911744c70364b24fcaff1860 (patch)
tree26f83df78f2b7fd675de27c0ea315616b0cd7dde /indra/llcommon/llmemory.h
parent122a01cb9c0327e94699f108828997c024d6937b (diff)
parent3db09928717e71868a8bddfffe84a29e09a74c9b (diff)
Merge
Diffstat (limited to 'indra/llcommon/llmemory.h')
-rw-r--r--indra/llcommon/llmemory.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 6a2323e7d8..d4f8c152e9 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -61,25 +61,29 @@ 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);
+ memcpy(ret, ptr, old_size);
+ ll_aligned_free_16(ptr);
+ return ret;
#endif
}
#else // USE_TCMALLOC