8#ifndef TRITON_MEMALLOC_H 
    9#define TRITON_MEMALLOC_H 
   15#define TRITONAPI __cdecl 
   21#define TRITON_DELETE delete 
   22#define TRITON_MALLOC Allocator::GetAllocator()->alloc 
   23#define TRITON_FREE Allocator::GetAllocator()->dealloc 
   41    virtual void * TRITONAPI 
alloc(
size_t bytes);
 
   57            sAllocator = &sDefaultAllocator;
 
   73#if (!(_MSC_VER < 1300)) 
   75    void *
operator new(
size_t bytes) {
 
   76        return TRITON_MALLOC(bytes);
 
   79    void operator delete(
void *p) {
 
   89#define TRITON_VECTOR(T) std::vector< T > 
   90#define TRITON_MAP(A, B) std::map< A, B > 
   91#define TRITON_SET(T) std::set< T > 
   92#define TRITON_LIST(T) std::list< T > 
   93#define TRITON_STRING std::string 
   94#define TRITON_STACK(T) std::stack< T > 
  100#define MAX_ALLOCATOR_SIZE 100E6 
  107    typedef T value_type;
 
  109    typedef const T* const_pointer;
 
  110    typedef T&       reference;
 
  111    typedef const T& const_reference;
 
  113    typedef std::size_t size_type;
 
  114    typedef std::ptrdiff_t difference_type;
 
  119        typedef TritonAllocator< U > other;
 
  123    pointer address (reference value)
 const {
 
  126    const_pointer address (const_reference value)
 const {
 
  133    TritonAllocator() throw() {
 
  135    TritonAllocator(
const TritonAllocator& ) 
throw() {
 
  139    TritonAllocator (
const TritonAllocator< U > &) 
throw() {
 
  142    ~TritonAllocator() throw() {
 
  146    size_type max_size () 
const throw() {
 
  147        return (size_type)(MAX_ALLOCATOR_SIZE / 
sizeof(T));
 
  151    pointer allocate (size_type num, 
const void* = 0) {
 
  157    void construct (pointer p, 
const T& value) {
 
  159        ::new ((
void*)p)T(value);
 
  163    void destroy (pointer p) {
 
  169    void deallocate (pointer p, size_type ) {
 
  175template <
class T1, 
class T2>
 
  176bool operator== (
const TritonAllocator<T1>&, 
const TritonAllocator<T2>&) 
throw()
 
  180template <
class T1, 
class T2>
 
  181bool operator!= (
const TritonAllocator<T1>&, 
const TritonAllocator<T2>&) 
throw()
 
  188#define TRITON_VECTOR(T) std::vector<T, TritonAllocator< T > > 
  189#define TRITON_MAP(A, B) std::map<A, B, std::less< A >, TritonAllocator< std::pair<A const, B > > > 
  190#define TRITON_SET(T) std::set<T, std::less< T >, TritonAllocator< T > > 
  191#define TRITON_LIST(T) std::list<T, TritonAllocator< T > > 
  192#define TRITON_STRING std::basic_string<char, std::char_traits<char>, TritonAllocator<char> > 
  193#define TRITON_STACK(T) std::stack<T, std::deque< T, TritonAllocator< T > > > 
  202    TRITON_LAZY() : obj(0) {}
 
  203    virtual ~TRITON_LAZY() {
 
  204        if (obj) TRITON_DELETE obj;
 
  208        if (!obj) obj = TRITON_NEW T;
 
You may extend the Allocator class to hook your own memory management scheme into Triton.
Definition: MemAlloc.h:35
virtual void TRITONAPI dealloc(void *p)
Free a block of memory; defaults to free()
static void TRITONAPI SetAllocator(Allocator *a)
Sets a new static allocator object.
Definition: MemAlloc.h:53
static Allocator *TRITONAPI GetAllocator()
Retrieves the static allocator object.
Definition: MemAlloc.h:47
virtual void *TRITONAPI alloc(size_t bytes)
Allocate a block of memory; defaults to malloc()
This base class for all Triton objects intercepts the new and delete operators, routing them through ...
Definition: MemAlloc.h:71