Преглед изворни кода

Remove nonsense from ProxyAllocator

Daniele Bartolini пре 11 година
родитељ
комит
61c96ffebe

+ 0 - 28
engine/console_server.cpp

@@ -185,7 +185,6 @@ void ConsoleServer::process(TCPSocket client, const char* request)
 	// Determine request type
 	if (type == "ping") process_ping(client, request);
 	else if (type == "script") process_script(client, request);
-	else if (type == "stats") process_stats(client, request);
 	else if (type == "command") process_command(client, request);
 	else if (type == "filesystem") processs_filesystem(client, request);
 	else CE_FATAL("Request unknown.");
@@ -206,33 +205,6 @@ void ConsoleServer::process_script(TCPSocket /*client*/, const char* msg)
 	device()->lua_environment()->execute_string(script.c_str());
 }
 
-void ConsoleServer::process_stats(TCPSocket client, const char* /*msg*/)
-{
-	using namespace string_stream;
-
-	TempAllocator2048 alloc;
-	StringStream response(alloc);
-
-	response << "{\"type\":\"response\",";
-	response << "{\"allocators\":[";
-
-	// Walk all proxy allocators
-	ProxyAllocator* proxy = ProxyAllocator::begin();
-	while (proxy != NULL)
-	{
-		response << "{";
-		response << "\"name\":\"" << proxy->name() << "\",";
-		response << "\"allocated_size\":\"" << proxy->allocated_size() << "\"";
-		response << "},";
-
-		proxy = ProxyAllocator::next(proxy);
-	}
-
-	response << "]" << "}";
-
-	send(client, c_str(response));
-}
-
 void ConsoleServer::process_command(TCPSocket /*client*/, const char* msg)
 {
 	JSONParser parser(msg);

+ 0 - 1
engine/console_server.h

@@ -67,7 +67,6 @@ private:
 
 	void process_ping(TCPSocket client, const char* msg);
 	void process_script(TCPSocket client, const char* msg);
-	void process_stats(TCPSocket client, const char* msg);
 	void process_command(TCPSocket client, const char* msg);
 	void processs_filesystem(TCPSocket client, const char* msg);
 

+ 1 - 67
engine/core/memory/proxy_allocator.cpp

@@ -3,39 +3,23 @@
  * License: https://github.com/taylor001/crown/blob/master/LICENSE
  */
 
-#include "assert.h"
 #include "proxy_allocator.h"
-#include "string_utils.h"
-#include "mutex.h"
+#include "assert.h"
 
 namespace crown
 {
 
-static ProxyAllocator* g_proxy_allocators_head = NULL;
-static Mutex g_proxy_allocators_mutex;
-
 ProxyAllocator::ProxyAllocator(const char* name, Allocator& allocator)
 	: _allocator(allocator)
 	, _name(name)
 	, _total_allocated(0)
-	, _next(NULL)
 {
-	ScopedMutex sm(g_proxy_allocators_mutex);
-
 	CE_ASSERT(name != NULL, "Name must be != NULL");
-
-	if(g_proxy_allocators_head != NULL)
-	{
-		_next = g_proxy_allocators_head;
-	}
-
-	g_proxy_allocators_head = this;
 }
 
 void* ProxyAllocator::allocate(size_t size, size_t align)
 {
 	_total_allocated += size;
-
 	return _allocator.allocate(size, align);
 }
 
@@ -54,54 +38,4 @@ const char* ProxyAllocator::name() const
 	return _name;
 }
 
-uint32_t ProxyAllocator::count()
-{
-	ScopedMutex sm(g_proxy_allocators_mutex);
-
-	const ProxyAllocator* head = g_proxy_allocators_head;
-	uint32_t count = 0;
-
-	while (head != NULL)
-	{
-		++count;
-		head = head->_next;
-	}
-
-	return count;
-}
-
-ProxyAllocator* ProxyAllocator::find(const char* name)
-{
-	ScopedMutex sm(g_proxy_allocators_mutex);
-
-	ProxyAllocator* head = g_proxy_allocators_head;
-
-	while (head != NULL)
-	{
-		if (strcmp(name, head->name()) == 0)
-		{
-			return head;
-		}
-
-		head = head->_next;
-	}
-
-	return NULL;
-}
-
-ProxyAllocator* ProxyAllocator::begin()
-{
-	return g_proxy_allocators_head;
-}
-
-ProxyAllocator* ProxyAllocator::next(ProxyAllocator* a)
-{
-	if (a == NULL)
-	{
-		return NULL;
-	}
-
-	return a->_next;
-}
-
 } // namespace crown

+ 1 - 20
engine/core/memory/proxy_allocator.h

@@ -6,7 +6,6 @@
 #pragma once
 
 #include "allocator.h"
-#include "macros.h"
 
 namespace crown
 {
@@ -35,30 +34,12 @@ public:
 	/// Returns the name of the proxy allocator
 	const char* name() const;
 
-public:
-
-	/// Returns the total number of proxy allocators.
-	/// in the global list.
-	static uint32_t count();
-
-	/// Returns the proxy allocator @name or NULL if not found.
-	static ProxyAllocator* find(const char* name);
-
-	/// Returns the first proxy allocator in the global list or
-	/// NULL if the list is empty.
-	static ProxyAllocator* begin();
-
-	/// Returns the next proxy allocator to @a a in the global list
-	/// or NULL if end-of-list is reached.
-	static ProxyAllocator* next(ProxyAllocator* a);
-
 private:
 
 	Allocator& _allocator;
-	
+
 	const char* _name;
 	size_t _total_allocated;
-	ProxyAllocator* _next;
 };
 
 } // namespace crown