1 //===--- Allocator.h - Simple memory allocation abstraction -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Chris Lattner and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the MallocAllocator and BumpPtrAllocator interfaces.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_ALLOCATOR_H
15 #define LLVM_SUPPORT_ALLOCATOR_H
21 class MallocAllocator {
27 void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
28 void Deallocate(void *Ptr) { free(Ptr); }
29 void PrintStats() const {}
32 /// BumpPtrAllocator - This allocator is useful for containers that need very
33 /// simple memory allocation strategies. In particular, this just keeps
34 /// allocating memory, and never deletes it until the entire block is dead. This
35 /// makes allocation speedy, but must only be used when the trade-off is ok.
36 class BumpPtrAllocator {
43 void *Allocate(unsigned Size, unsigned Alignment);
44 void Deallocate(void *Ptr) {}
45 void PrintStats() const;
48 } // end namespace clang