TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::AreaMemoryManager::Buffer Class Reference

Public Member Functions

 Buffer (size_t size)
 
 ~Buffer ()
 
void * alloc (size_t s)
 

Private Attributes

uint8m_first
 
size_t m_size
 
size_t m_used
 

Constructor & Destructor Documentation

G3D::AreaMemoryManager::Buffer::Buffer ( size_t  size)
18  : m_size(size), m_used(0) {
19  // Allocate space for a lot of buffers.
20  m_first = (uint8*)::malloc(m_size);
21 }
uint8 * m_first
Definition: AreaMemoryManager.h:37
size_t m_used
Definition: AreaMemoryManager.h:39
size_t m_size
Definition: AreaMemoryManager.h:38
uint8_t uint8
Definition: Define.h:152
G3D::AreaMemoryManager::Buffer::~Buffer ( )
24  {
25  ::free(m_first);
26 }
uint8 * m_first
Definition: AreaMemoryManager.h:37
virtual void free(void *x)
Definition: AreaMemoryManager.cpp:77

+ Here is the call graph for this function:

Member Function Documentation

void * G3D::AreaMemoryManager::Buffer::alloc ( size_t  s)

Returns NULL if out of space

29  {
30  if (s + m_used > m_size) {
31  return NULL;
32  } else {
33  void* old = m_first + m_used;
34  m_used += s;
35  return old;
36  }
37 }
uint8 * m_first
Definition: AreaMemoryManager.h:37
arena_t NULL
Definition: jemalloc_internal.h:624
size_t m_used
Definition: AreaMemoryManager.h:39
size_t m_size
Definition: AreaMemoryManager.h:38

Member Data Documentation

uint8* G3D::AreaMemoryManager::Buffer::m_first
private
size_t G3D::AreaMemoryManager::Buffer::m_size
private
size_t G3D::AreaMemoryManager::Buffer::m_used
private

The documentation for this class was generated from the following files: