databuffer.h

changeset 40
9e4f785501db
parent 39
07b7ab8080cf
child 41
47e686c96d8f
--- a/databuffer.h	Mon Jul 30 11:14:02 2012 +0300
+++ b/databuffer.h	Mon Jul 30 11:34:57 2012 +0300
@@ -138,10 +138,8 @@
 		if (!other)
 			return;
 		
-		for (unsigned int x = 0; x < other->writesize; x++) {
-			unsigned char c = *(other->buffer+x);
-			Write<unsigned char> (c);
-		}
+		for (unsigned int x = 0; x < other->writesize; x++)
+			Write<unsigned char> (*(other->buffer+x));
 		
 		// Merge its marks and references
 		unsigned int u = 0;
@@ -162,6 +160,14 @@
 		delete other;
 	}
 	
+	// Clones this databuffer to a new one and returns it.
+	DataBuffer* Clone () {
+		DataBuffer* other = new DataBuffer;
+		for (unsigned int x = 0; x < writesize; x++)
+			other->Write<unsigned char> (*(buffer+x));
+		return other;
+	}
+	
 	// ====================================================================
 	// Adds a mark to the buffer. A mark is a reference to a particular
 	// position in the bytecode. The actual permanent position cannot
@@ -229,6 +235,12 @@
 			return;
 		marks[mark]->pos = writesize;
 	}
+	
+	// Dump the buffer (for debugging purposes)
+	void Dump() {
+		for (unsigned int x = 0; x < writesize; x++)
+			printf ("%d. [%d]\n", x, *(buffer+x));
+	}
 };
 
 #endif // __DATABUFFER_H__
\ No newline at end of file

mercurial