diff dmd/OutBuffer.d @ 5:63623152e82a

Fixed memory corruption bug which was introduced when attempting to restore GC functionality
author dkoroskin <>
date Tue, 08 Dec 2009 21:39:17 +0300
parents d706d958e4e8
children 832f71e6f96c
line wrap: on
line diff
--- a/dmd/OutBuffer.d	Mon Oct 26 16:28:19 2009 +0300
+++ b/dmd/OutBuffer.d	Tue Dec 08 21:39:17 2009 +0300
@@ -7,6 +7,7 @@
 import core.stdc.string;
 
 import core.memory;
+import core.stdc.stdlib;
 
 class OutBuffer
 {
@@ -41,7 +42,7 @@
 		if (size - offset < nbytes)
 		{
 			size = (offset + nbytes) * 2;
-			data = cast(ubyte*)GC.realloc(data, size);
+			data = cast(ubyte*)realloc(data, size);
 		}
 	}
 	
@@ -266,7 +267,12 @@
 	
     string toChars()
 	{
-		return getString().idup;
+	   char[] s = getString();
+	   char* copy = cast(char*)malloc(s.length);
+	   memcpy(copy, s.ptr, s.length);
+	   return assumeUnique(copy[0..s.length]);
+
+		//return getString().idup;
 	}
 
     final string extractString()