From 268ddbd76f963f8abca784bfa33f43d779181c72 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 10 Dec 2011 17:20:34 +0100 Subject: [PATCH] Fix a few function signatures in the guarded heap. * Not including malloc.h caused the memalign() signature to not be a C signature, therefore leading to linking errors. Fix the missing include and explicitly add extern "C" as well. * Some remaining asterisk style cleanup. --- .../libroot/posix/malloc_debug/guarded_heap.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/system/libroot/posix/malloc_debug/guarded_heap.cpp b/src/system/libroot/posix/malloc_debug/guarded_heap.cpp index 8ad3cdb97a..051d913b14 100644 --- a/src/system/libroot/posix/malloc_debug/guarded_heap.cpp +++ b/src/system/libroot/posix/malloc_debug/guarded_heap.cpp @@ -4,6 +4,7 @@ */ +#include #include #include #include @@ -943,7 +944,7 @@ __init_heap_post_env(void) // #pragma mark - Public API -extern "C" void * +extern "C" void* sbrk_hook(long) { debug_printf("sbrk not supported on malloc debug\n"); @@ -952,7 +953,7 @@ sbrk_hook(long) } -void* +extern "C" void* memalign(size_t alignment, size_t size) { if (size == 0) @@ -962,14 +963,14 @@ memalign(size_t alignment, size_t size) } -void* +extern "C" void* malloc(size_t size) { return memalign(0, size); } -void +extern "C" void free(void* address) { if (!guarded_heap_free(address)) @@ -977,7 +978,7 @@ free(void* address) } -void* +extern "C" void* realloc(void* address, size_t newSize) { if (newSize == 0) { @@ -992,10 +993,10 @@ realloc(void* address, size_t newSize) } -void * +extern "C" void* calloc(size_t numElements, size_t size) { - void *address = malloc(numElements * size); + void* address = malloc(numElements * size); if (address != NULL) memset(address, 0, numElements * size); @@ -1003,7 +1004,7 @@ calloc(size_t numElements, size_t size) } -extern "C" void * +extern "C" void* valloc(size_t size) { return memalign(B_PAGE_SIZE, size);