Nugget
core_allocator.h
1 // Copyright (c) Electronic Arts Inc. All rights reserved.
4 
5 #ifndef EASTL_CORE_ALLOCATOR_H
6 #define EASTL_CORE_ALLOCATOR_H
7 
8 #if EASTL_CORE_ALLOCATOR_ENABLED
9 
10 #include <coreallocator/icoreallocator.h>
11 
12 namespace EA
13 {
14  namespace Allocator
15  {
28 
29  class EASTLCoreAllocatorImpl : public ICoreAllocator
30  {
31  public:
32  virtual void* Alloc(size_t size, const char* name, unsigned int flags)
33  {
34  return ::operator new[](size, name, flags, 0, __FILE__, __LINE__);
35  }
36 
37  virtual void* Alloc(size_t size, const char* name, unsigned int flags, unsigned int alignment, unsigned int alignOffset = 0)
38  {
39  return ::operator new[](size, alignment, alignOffset, name, flags, 0, __FILE__, __LINE__);
40  }
41 
42  virtual void Free(void* ptr, size_t size = 0)
43  {
44  ::operator delete(static_cast<char*>(ptr));
45  }
46 
47  virtual void* AllocDebug(size_t size, const DebugParams debugParams, unsigned int flags)
48  {
49  return Alloc(size, debugParams.mName, flags);
50  }
51 
52  virtual void* AllocDebug(size_t size, const DebugParams debugParams, unsigned int flags, unsigned int align, unsigned int alignOffset = 0)
53  {
54  return Alloc(size, debugParams.mName, flags, align, alignOffset);
55  }
56 
57  static EASTLCoreAllocatorImpl* GetDefaultAllocator();
58  };
59 
60  inline EASTLCoreAllocatorImpl* EASTLCoreAllocatorImpl::GetDefaultAllocator()
61  {
62  static EASTLCoreAllocatorImpl allocator;
63  return &allocator;
64  }
65  }
66 }
67 
68 #endif // EASTL_CORE_ALLOCATOR_ENABLED
69 #endif // EASTL_CORE_ALLOCATOR_H
70 
EASTL_API allocator * GetDefaultAllocator()
Definition: allocator_eastl.cpp:30