[Libreoffice-commits] core.git: include/rtl sal/osl

Stephan Bergmann sbergman at redhat.com
Fri Feb 28 00:30:59 PST 2014


 include/rtl/alloc.h  |   13 +++++++++++--
 sal/osl/unx/memory.c |   13 ++++++++++---
 2 files changed, 21 insertions(+), 5 deletions(-)

New commits:
commit 9dfa48405fff9fe03519804c962d0f73951deb64
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Feb 28 09:30:06 2014 +0100

    Missing @since tags, and adapt to semantics of posix_memalign
    
    Change-Id: I677d973fbcf118111b5fc93b09143c66b0afb0d9

diff --git a/include/rtl/alloc.h b/include/rtl/alloc.h
index 01a556b..6a80492 100644
--- a/include/rtl/alloc.h
+++ b/include/rtl/alloc.h
@@ -96,14 +96,20 @@ SAL_DLLPUBLIC void SAL_CALL rtl_freeZeroMemory (
 ) SAL_THROW_EXTERN_C();
 
 
-/** Allocate memory.
+/** Allocate aligned memory.
 
     A call to this function will return NULL upon the requested
     memory size being either zero or larger than currently allocatable.
 
-    @param Alignment alignment in bytes.
+    Memory obtained through this function must be freed with
+    rtl_freeAlignedMemory.
+
+    @param Alignment [in] alignment in bytes, must be a power of two multiple of
+        sizeof(void*).
     @param  Bytes [in] memory size.
     @return pointer to allocated memory.
+
+    @since LibreOffice 4.3
  */
 SAL_DLLPUBLIC void* SAL_CALL rtl_allocateAlignedMemory (
     sal_Size Alignment,
@@ -112,8 +118,11 @@ SAL_DLLPUBLIC void* SAL_CALL rtl_allocateAlignedMemory (
 
 
 /** Free memory allocated with rtl_allocateAlignedMemory.
+
     @param  Ptr   [in] pointer to previously allocated memory.
     @return none. Memory is released. Ptr is invalid.
+
+    @since LibreOffice 4.3
  */
 SAL_DLLPUBLIC void SAL_CALL rtl_freeAlignedMemory (
     void *   Ptr
diff --git a/sal/osl/unx/memory.c b/sal/osl/unx/memory.c
index 2b6c20f..ca241b1 100644
--- a/sal/osl/unx/memory.c
+++ b/sal/osl/unx/memory.c
@@ -19,9 +19,16 @@ void* osl_aligned_alloc( sal_Size align, sal_Size size )
 #ifdef __ANDROID__
     return memalign(align, size);
 #else
-    void* ptr;
-    int err = posix_memalign(&ptr, align, size);
-    return err ? NULL : ptr;
+    if (size == 0)
+    {
+        return NULL;
+    }
+    else
+    {
+        void* ptr;
+        int err = posix_memalign(&ptr, align, size);
+        return err ? NULL : ptr;
+    }
 #endif
 }
 


More information about the Libreoffice-commits mailing list