Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Side by Side Diff: src/shared/platform/posix/aligned_malloc.c

Issue 11364047: Android doesn't have posix_memalign(), so use memalign() (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include "native_client/src/shared/platform/aligned_malloc.h" 7 #include "native_client/src/shared/platform/aligned_malloc.h"
8 8
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
11 11
12 void *NaClAlignedMalloc(size_t size, size_t alignment) { 12 void *NaClAlignedMalloc(size_t size, size_t alignment) {
13 /*
14 * Bionic in Android ICS (4.0) and earlier doesn't have
15 * posix_memalign(), so we shall use memalign(), which
16 * luckily returns free()'able memory.
Mark Seaborn 2012/11/06 13:54:44 How about: "luckily, in Bionic, returns free()'abl
17 * TODO(olonho): once/if we'll obsolete 4.0 support remove this
18 * #ifdef.
19 */
20 #if NACL_ANDROID
21 return memalign(alignment, size);
22 #else
13 void *block; 23 void *block;
14 if (posix_memalign(&block, alignment, size) != 0) 24 if (posix_memalign(&block, alignment, size) != 0)
15 return NULL; 25 return NULL;
16 return block; 26 return block;
27 #endif
17 } 28 }
18 29
19 void NaClAlignedFree(void *block) { 30 void NaClAlignedFree(void *block) {
20 free(block); 31 free(block);
21 } 32 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698