Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 } |
| OLD | NEW |