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 | |
|
Mark Seaborn
2012/11/02 15:35:57
Don't change the spacing unnecessarily, please. T
Nikolay
2012/11/06 11:09:05
Done.
| |
| 12 void *NaClAlignedMalloc(size_t size, size_t alignment) { | 11 void *NaClAlignedMalloc(size_t size, size_t alignment) { |
| 12 #if NACL_ANDROID | |
| 13 return memalign(alignment, size); | |
|
Mark Seaborn
2012/11/02 15:35:57
Android added posix_memalign() in December 2011 in
Nikolay
2012/11/06 11:09:05
Done.
| |
| 14 #else | |
| 13 void *block; | 15 void *block; |
| 14 if (posix_memalign(&block, alignment, size) != 0) | 16 if (posix_memalign(&block, alignment, size) != 0) |
| 15 return NULL; | 17 return NULL; |
| 16 return block; | 18 return block; |
| 19 #endif | |
| 17 } | 20 } |
| 18 | 21 |
| 19 void NaClAlignedFree(void *block) { | 22 void NaClAlignedFree(void *block) { |
| 20 free(block); | 23 free(block); |
| 21 } | 24 } |
| OLD | NEW |