changeset 180:0622fff7810a

Fixed a few memory allocation related issues
author korDen
date Sun, 17 Oct 2010 23:23:28 +0400
parents cd48cb899aee
children aa70dca07cb0
files buildHelper.d dmd/PragmaDeclaration.d dmd/StringExp.d dmd/StringTable.d dmd/SwitchStatement.d dmd/codegen/Util.d
diffstat 6 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/buildHelper.d	Sun Oct 17 20:56:07 2010 +0400
+++ b/buildHelper.d	Sun Oct 17 23:23:28 2010 +0400
@@ -8,7 +8,7 @@
 import std.string: replace, format;
 import std.zip;
 
-enum dmdVersionDefault = "2.039";
+enum dmdVersionDefault = "2.040";
 enum dmdArchiveBaseURL = "http://ftp.digitalmars.com/";
 enum dmdLib = "dmd.lib";
 version(Windows)
@@ -166,6 +166,10 @@
 	copyAndPatch("mars.c", "mars2.c", (ref string data) {
 		data = data.replace("int main(int argc, char *argv[])", "int HIDE_main(int argc, char *argv[])");
 	});
+	
+	copyAndPatch("util.c", "util.c", (ref string data) {
+		data = data.replace("void util_assert(char *file,int line)", "void HIDE_util_assert(char *file,int line)");
+	});
 
 	// Apply patch
 	doChDir("../../..");
--- a/dmd/PragmaDeclaration.d	Sun Oct 17 20:56:07 2010 +0400
+++ b/dmd/PragmaDeclaration.d	Sun Oct 17 23:23:28 2010 +0400
@@ -21,7 +21,7 @@
 import dmd.backend.Util;
 import dmd.backend.Symbol;
 
-import core.memory;
+import core.stdc.stdlib : malloc;
 
 class PragmaDeclaration : AttribDeclaration
 {
@@ -252,7 +252,7 @@
 			assert(e.op == TOKstring);
 
 			auto se = cast(StringExp)e;
-			char* name = cast(char*)GC.malloc(se.len + 1);
+			char* name = cast(char*)malloc(se.len + 1);
 			memcpy(name, se.string_, se.len);
 			name[se.len] = 0;
 		version (OMFOBJ) {
--- a/dmd/StringExp.d	Sun Oct 17 20:56:07 2010 +0400
+++ b/dmd/StringExp.d	Sun Oct 17 23:23:28 2010 +0400
@@ -858,7 +858,7 @@
 			e.Eoper = OPER.OPstring;
 static if (true) {
 			// Match MEM_PH_FREE for OPstring in ztc\el.c
-			e.EV.ss.Vstring = cast(char*)GC.malloc((len + 1) * sz); /// !
+			e.EV.ss.Vstring = cast(char*)malloc((len + 1) * sz);
 			memcpy(e.EV.ss.Vstring, string_, (len + 1) * sz);
 } else {
 			e.EV.ss.Vstring = cast(char*)string_;
--- a/dmd/StringTable.d	Sun Oct 17 20:56:07 2010 +0400
+++ b/dmd/StringTable.d	Sun Oct 17 23:23:28 2010 +0400
@@ -15,14 +15,14 @@
 struct StringTable
 {
 	Object[string] table;
-
+/*
 	~this()
 	{
 		foreach (k, v; table) {
 			delete v;
 		}
 	}
-
+*/
 	Object* lookup(string s)
 	{
 		return s in table;
--- a/dmd/SwitchStatement.d	Sun Oct 17 20:56:07 2010 +0400
+++ b/dmd/SwitchStatement.d	Sun Oct 17 23:23:28 2010 +0400
@@ -487,7 +487,7 @@
 		block_next(blx,BCswitch,null);
 
         // Corresponding free is in block_free
-		targ_llong* pu = cast(targ_llong*) GC.malloc(targ_llong.sizeof * (numcases + 1));
+		targ_llong* pu = cast(targ_llong*) malloc(targ_llong.sizeof * (numcases + 1));
 		mystate.switchBlock.Bswitch = pu;
 		/* First pair is the number of cases, and the default block
 		 */
--- a/dmd/codegen/Util.d	Sun Oct 17 20:56:07 2010 +0400
+++ b/dmd/codegen/Util.d	Sun Oct 17 23:23:28 2010 +0400
@@ -1132,7 +1132,7 @@
 					es.Eoper = OPER.OPstring;
 
 					// Match MEM_PH_FREE for OPstring in ztc\el.c
-					es.EV.ss.Vstring = cast(char*)GC.malloc(len);	/// !
+					es.EV.ss.Vstring = cast(char*)malloc(len);
 					memcpy(es.EV.ss.Vstring, &e.EV, len);
 
 					es.EV.ss.Vstrlen = len;