Explorar el Código

Add global linked-list of proxy allocators

Daniele Bartolini hace 12 años
padre
commit
69375d1a0b
Se han modificado 2 ficheros con 16 adiciones y 2 borrados
  1. 11 1
      engine/core/mem/ProxyAllocator.cpp
  2. 5 1
      engine/core/mem/ProxyAllocator.h

+ 11 - 1
engine/core/mem/ProxyAllocator.cpp

@@ -31,12 +31,22 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
+static ProxyAllocator* g_proxy_allocators_head = NULL;
+
 //-----------------------------------------------------------------------------
 ProxyAllocator::ProxyAllocator(const char* name, Allocator& allocator) :
 	m_allocator(allocator),
-	m_name(name)
+	m_name(name),
+	m_next(NULL)
 {
 	CE_ASSERT(name != NULL, "Name must be != NULL");
+
+	if(g_proxy_allocators_head != NULL)
+	{
+		m_next = g_proxy_allocators_head;
+	}
+
+	g_proxy_allocators_head = this;
 }
 
 //-----------------------------------------------------------------------------

+ 5 - 1
engine/core/mem/ProxyAllocator.h

@@ -34,7 +34,9 @@ namespace crown
 
 class Allocator;
 
-/// Offers the facility to tag allocations by a string identifier.
+/// Offers the facility to tag allocators by a string identifier.
+/// Proxy allocator is appended to a global linked list when instantiated
+/// so that it is possible to later visit that list for debugging purposes.
 class ProxyAllocator
 {
 public:
@@ -55,6 +57,8 @@ private:
 
 	Allocator&		m_allocator;
 	const char*		m_name;
+
+	ProxyAllocator*	m_next;
 };
 
 } // namespace crown