1 //===-- scudo_interceptors.cpp ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// Linux specific malloc interception functions.
12 //===----------------------------------------------------------------------===//
14 #include "sanitizer_common/sanitizer_platform.h"
17 #include "scudo_allocator.h"
19 #include "interception/interception.h"
21 using namespace __scudo;
23 INTERCEPTOR(void, free, void *ptr) {
24 scudoFree(ptr, FromMalloc);
27 INTERCEPTOR(void, cfree, void *ptr) {
28 scudoFree(ptr, FromMalloc);
31 INTERCEPTOR(void*, malloc, uptr size) {
32 return scudoMalloc(size, FromMalloc);
35 INTERCEPTOR(void*, realloc, void *ptr, uptr size) {
36 return scudoRealloc(ptr, size);
39 INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) {
40 return scudoCalloc(nmemb, size);
43 INTERCEPTOR(void*, valloc, uptr size) {
44 return scudoValloc(size);
47 INTERCEPTOR(void*, memalign, uptr alignment, uptr size) {
48 return scudoMemalign(alignment, size);
51 INTERCEPTOR(void*, __libc_memalign, uptr alignment, uptr size) {
52 return scudoMemalign(alignment, size);
55 INTERCEPTOR(void*, pvalloc, uptr size) {
56 return scudoPvalloc(size);
59 INTERCEPTOR(void*, aligned_alloc, uptr alignment, uptr size) {
60 return scudoAlignedAlloc(alignment, size);
63 INTERCEPTOR(int, posix_memalign, void **memptr, uptr alignment, uptr size) {
64 return scudoPosixMemalign(memptr, alignment, size);
67 INTERCEPTOR(uptr, malloc_usable_size, void *ptr) {
68 return scudoMallocUsableSize(ptr);
71 INTERCEPTOR(int, mallopt, int cmd, int value) {
75 #endif // SANITIZER_LINUX