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.
This commit is contained in:
Michael Lotz
2011-12-10 17:24:10 +01:00
parent 3de380692a
commit 268ddbd76f
@@ -4,6 +4,7 @@
*/ */
#include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -943,7 +944,7 @@ __init_heap_post_env(void)
// #pragma mark - Public API // #pragma mark - Public API
extern "C" void * extern "C" void*
sbrk_hook(long) sbrk_hook(long)
{ {
debug_printf("sbrk not supported on malloc debug\n"); 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) memalign(size_t alignment, size_t size)
{ {
if (size == 0) if (size == 0)
@@ -962,14 +963,14 @@ memalign(size_t alignment, size_t size)
} }
void* extern "C" void*
malloc(size_t size) malloc(size_t size)
{ {
return memalign(0, size); return memalign(0, size);
} }
void extern "C" void
free(void* address) free(void* address)
{ {
if (!guarded_heap_free(address)) if (!guarded_heap_free(address))
@@ -977,7 +978,7 @@ free(void* address)
} }
void* extern "C" void*
realloc(void* address, size_t newSize) realloc(void* address, size_t newSize)
{ {
if (newSize == 0) { if (newSize == 0) {
@@ -992,10 +993,10 @@ realloc(void* address, size_t newSize)
} }
void * extern "C" void*
calloc(size_t numElements, size_t size) calloc(size_t numElements, size_t size)
{ {
void *address = malloc(numElements * size); void* address = malloc(numElements * size);
if (address != NULL) if (address != NULL)
memset(address, 0, numElements * size); 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) valloc(size_t size)
{ {
return memalign(B_PAGE_SIZE, size); return memalign(B_PAGE_SIZE, size);