1 //===-- scudo_allocator.h ---------------------------------------*- 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 /// Header for scudo_allocator.cpp.
12 //===----------------------------------------------------------------------===//
14 #ifndef SCUDO_ALLOCATOR_H_
15 #define SCUDO_ALLOCATOR_H_
18 # error "The Scudo hardened allocator currently only supports x86_64."
21 #include "scudo_flags.h"
23 #include "sanitizer_common/sanitizer_allocator.h"
28 FromMalloc = 0, // Memory block came from malloc, realloc, calloc, etc.
29 FromNew = 1, // Memory block came from operator new.
30 FromNewArray = 2, // Memory block came from operator new [].
31 FromMemalign = 3, // Memory block came from memalign, posix_memalign, etc.
34 struct AllocatorOptions {
36 u32 ThreadLocalQuarantineSizeKb;
38 bool DeallocationTypeMismatch;
39 bool DeleteSizeMismatch;
42 void setFrom(const Flags *f, const CommonFlags *cf);
43 void copyTo(Flags *f, CommonFlags *cf) const;
46 void initAllocator(const AllocatorOptions &options);
47 void drainQuarantine();
49 void *scudoMalloc(uptr Size, AllocType Type);
50 void scudoFree(void *Ptr, AllocType Type);
51 void scudoSizedFree(void *Ptr, uptr Size, AllocType Type);
52 void *scudoRealloc(void *Ptr, uptr Size);
53 void *scudoCalloc(uptr NMemB, uptr Size);
54 void *scudoMemalign(uptr Alignment, uptr Size);
55 void *scudoValloc(uptr Size);
56 void *scudoPvalloc(uptr Size);
57 int scudoPosixMemalign(void **MemPtr, uptr Alignment, uptr Size);
58 void *scudoAlignedAlloc(uptr Alignment, uptr Size);
59 uptr scudoMallocUsableSize(void *Ptr);
61 } // namespace __scudo
63 #endif // SCUDO_ALLOCATOR_H_