sal/osl/unx/memory.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
New commits: commit dfc2e4573157abcb70418f9c7738acda63602ddd Author: Douglas Mencken <dougmenc...@gmail.com> Date: Sun Mar 30 02:32:16 2014 -0400 sal: add aligned memory allocation with malloc for OS X < 10.6 Note that posix_memalign is not available everywhere (as are its replacements like memalign). For example, Darwin/OSX <10.6 has neither posix_memalign or memalign. Incorporating changes by Stephan Bergmann <sberg...@redhat.com>. Change-Id: I4a02b40c36d353c2b7a78d0bacb3b14e1f2d94da Reviewed-on: https://gerrit.libreoffice.org/8405 Reviewed-by: Stephan Bergmann <sberg...@redhat.com> Tested-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sal/osl/unx/memory.c b/sal/osl/unx/memory.c index ca241b1..bde2fac 100644 --- a/sal/osl/unx/memory.c +++ b/sal/osl/unx/memory.c @@ -16,25 +16,36 @@ void* osl_aligned_alloc( sal_Size align, sal_Size size ) { -#ifdef __ANDROID__ - return memalign(align, size); -#else if (size == 0) { return NULL; } else { +#if defined __ANDROID__ + return memalign(align, size); +#elif defined MAC_OS_X_VERSION_MAX_ALLOWED && MAC_OS_X_VERSION_MAX_ALLOWED < 1060 + void* ptr = malloc(size + (align - 1) + sizeof(void*)); + if (!ptr) return NULL; + char* aptr = ((char*)ptr) + sizeof(void*); + aptr += (align - ((size_t)aptr & (align - 1))) & (align - 1); + ((void**)aptr)[-1] = ptr; + return aptr; +#else void* ptr; int err = posix_memalign(&ptr, align, size); return err ? NULL : ptr; - } #endif + } } void osl_aligned_free( void* p ) { +#if defined __APPLE__ && MAC_OS_X_VERSION_MAX_ALLOWED < 1060 + free(((void**)p)[-1]); +#else free(p); +#endif } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits