Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : */
9 :
10 : #include <internal/oslmemory.h>
11 :
12 : #include <stdlib.h>
13 : #ifdef __ANDROID__
14 : #include <malloc.h>
15 : #endif
16 :
17 28 : void* osl_aligned_alloc( sal_Size align, sal_Size size )
18 : {
19 28 : if (size == 0)
20 : {
21 0 : return NULL;
22 : }
23 : else
24 : {
25 : #if defined __ANDROID__
26 : return memalign(align, size);
27 : #else
28 : void* ptr;
29 28 : int err = posix_memalign(&ptr, align, size);
30 28 : return err ? NULL : ptr;
31 : #endif
32 : }
33 : }
34 :
35 28 : void osl_aligned_free( void* p )
36 : {
37 28 : free(p);
38 28 : }
39 :
40 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|