pointer.cpp

changeset 21
9aebaaafa5da
parent 19
6c5977e43e73
--- a/pointer.cpp	Sat Mar 16 15:45:20 2013 +0200
+++ b/pointer.cpp	Sat Mar 16 16:59:16 2013 +0200
@@ -2,28 +2,12 @@
 
 vector<objPointer*> g_pObjectPointers;
 
-// #define POINTER_DEBUG
-
-#ifdef POINTER_DEBUG
-#include <stdio.h>
-#define DEBUGMESSAGE printf
-#else
-#define DEBUGMESSAGE
-#endif
-
 void objPointer::replacePointers (LDObject* old, LDObject* repl) {
-	DEBUGMESSAGE ("replacing %p with %p\n", old, repl);
-	DEBUGMESSAGE ("%u objects in pointers\n", g_pObjectPointers.size());
-	
 	for (ulong i = 0; i < g_pObjectPointers.size(); ++i) {
 		objPointer* ptrptr = g_pObjectPointers[i];
-		DEBUGMESSAGE ("%lu. (%p <-> %p)\n", i, (*ptrptr).ptr, old);
-		if ((*ptrptr).ptr == old) {
-			DEBUGMESSAGE ("\treplacing... %p -> %p\n", (*ptrptr).ptr, repl);
+		
+		if ((*ptrptr).ptr == old)
 			(*ptrptr).ptr = repl;
-			
-			DEBUGMESSAGE ("%lu. (%p <-> %p)\n", i, (*ptrptr).ptr, old);
-		}
 	}
 }
 
@@ -40,15 +24,16 @@
 }
 
 void objPointer::serialize () {
-	DEBUGMESSAGE ("Adding %p to pointers (ptr = %p)... ", this, ptr);
 	g_pObjectPointers.push_back (this);
-	DEBUGMESSAGE ("%u objects in pointers\n", g_pObjectPointers.size());
 }
 
 void objPointer::unSerialize () {
-	DEBUGMESSAGE ("Removing %p from pointers... ", this);
 	for (ulong i = 0; i < g_pObjectPointers.size(); ++i)
 		if (g_pObjectPointers[i] == this)
 			g_pObjectPointers.erase (g_pObjectPointers.begin() + i);
-	DEBUGMESSAGE ("%u objects in pointers\n", g_pObjectPointers.size());
+}
+
+void objPointer::deleteObj (LDObject* obj) {
+	replacePointers (obj, nullptr);
+	delete obj;
 }
\ No newline at end of file

mercurial