From d81d0433a5482602a7cdae590b3a0ffdc5cb79f9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 31 Aug 2012 15:27:38 -0500 Subject: MAINT-1503 Fix for ll_aligned_realloc returning non-aligned pointers on linux --- indra/llcommon/llmemory.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 6a2323e7d8..ebef3f98d6 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -68,7 +68,11 @@ inline void* ll_aligned_realloc_16(void* ptr, size_t size) // returned hunk MUST #elif defined(LL_DARWIN) return realloc(ptr,size); // default osx malloc is 16 byte aligned. #else - return realloc(ptr,size); // FIXME not guaranteed to be aligned. + //FIXME: memcpy is SLOW + void* ret = ll_aligned_malloc_16(size); + memcpy(ret, ptr, old_size); + ll_aligned_free_16(ptr); + return ret; #endif } -- cgit v1.2.3 From 980d5a75556f802e412d24b14a48a49c76126e19 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 31 Aug 2012 16:30:58 -0500 Subject: MAINT-1503 Fix for ll_aligned_realloc returning non-aligned pointers on linux --- indra/llcommon/llmemory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index ebef3f98d6..36d2d9da37 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -61,7 +61,7 @@ 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_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) return _aligned_realloc(ptr, size, 16); -- cgit v1.2.3 From 3db09928717e71868a8bddfffe84a29e09a74c9b Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 7 Sep 2012 12:15:19 -0500 Subject: MAINT-1503 Fix for linux build --- indra/llcommon/llmemory.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 36d2d9da37..d4f8c152e9 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -61,6 +61,17 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi #endif } +inline void ll_aligned_free_16(void *p) +{ +#if defined(LL_WINDOWS) + _aligned_free(p); +#elif defined(LL_DARWIN) + return free(p); +#else + free(p); // posix_memalign() is compatible with heap deallocator +#endif +} + 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) @@ -75,17 +86,6 @@ inline void* ll_aligned_realloc_16(void* ptr, size_t size, size_t old_size) // r return ret; #endif } - -inline void ll_aligned_free_16(void *p) -{ -#if defined(LL_WINDOWS) - _aligned_free(p); -#elif defined(LL_DARWIN) - return free(p); -#else - free(p); // posix_memalign() is compatible with heap deallocator -#endif -} #else // USE_TCMALLOC // ll_aligned_foo_16 are not needed with tcmalloc #define ll_aligned_malloc_16 malloc -- cgit v1.2.3