[Sanitizer] include stdlib.h header to get malloc/free
llvm-svn: 158144
This commit is contained in:
parent
0b14fd855b
commit
94e2b7d040
|
@ -13,18 +13,16 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
#include "sanitizer_common.h"
|
||||
|
||||
// Provisional implementation.
|
||||
// FIXME: We should probably use more low-level allocator that would
|
||||
// mmap some pages and split them into chunks to fulfill requests.
|
||||
extern "C" void *__libc_malloc(__sanitizer::uptr size);
|
||||
extern "C" void __libc_free(void *ptr);
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace __sanitizer {
|
||||
|
||||
static const u64 kInternalAllocBlockMagic = 0x7A6CB03ABCEBC042ull;
|
||||
|
||||
void *InternalAlloc(uptr size) {
|
||||
void *p = __libc_malloc(size + sizeof(u64));
|
||||
void *p = malloc(size + sizeof(u64));
|
||||
((u64*)p)[0] = kInternalAllocBlockMagic;
|
||||
return (char*)p + sizeof(u64);
|
||||
}
|
||||
|
@ -34,7 +32,7 @@ void InternalFree(void *addr) {
|
|||
addr = (char*)addr - sizeof(u64);
|
||||
CHECK_EQ(((u64*)addr)[0], kInternalAllocBlockMagic);
|
||||
((u64*)addr)[0] = 0;
|
||||
__libc_free(addr);
|
||||
free(addr);
|
||||
}
|
||||
|
||||
} // namespace __sanitizer
|
||||
|
|
Loading…
Reference in New Issue