changeset 175:94b6033c07f3

get rid of globals malloc -> GC.malloc
author korDen
date Sun, 10 Oct 2010 03:48:06 +0400
parents af724d3510d7
children fa9a71a9f5a8
files dmd/BinExp.d dmd/ComplexExp.d dmd/DelegateExp.d dmd/FileName.d dmd/ForeachStatement.d dmd/FuncDeclaration.d dmd/Lexer.d dmd/OutBuffer.d dmd/PREC.d dmd/StringExp.d dmd/Util.d dmd/backend/Configv.d dmd/backend/Util.d dmd/backend/glue.d dmd/backend/iasm.d
diffstat 15 files changed, 25 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/BinExp.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/BinExp.d	Sun Oct 10 03:48:06 2010 +0400
@@ -1496,7 +1496,7 @@
 			 * presumably to optimize them with special CPU vector instructions.
 			 * List those library functions here, in alpha order.
 			 */
-			static const(char)*[] libArrayopFuncs =
+			enum const(char)*[] libArrayopFuncs =
 			[
 				"_arrayExpSliceAddass_a",
 				"_arrayExpSliceAddass_d",		// T[]+=T
--- a/dmd/ComplexExp.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/ComplexExp.d	Sun Oct 10 03:48:06 2010 +0400
@@ -220,7 +220,7 @@
 		return el_const(ty, &c);
 	}
 
-	static private char[6] zeropad;
+	static private __gshared char[6] zeropad;
 
 	override dt_t** toDt(dt_t** pdt)
 	{
--- a/dmd/DelegateExp.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/DelegateExp.d	Sun Oct 10 03:48:06 2010 +0400
@@ -87,7 +87,7 @@
 		printf("DelegateExp.castTo(this=%s, type=%s, t=%s)\n",
 			toChars(), type.toChars(), t.toChars());
 	}
-		static string msg = "cannot form delegate due to covariant return type";
+		enum string msg = "cannot form delegate due to covariant return type";
 
 		Expression e = this;
 		Type tb = t.toBasetype();
--- a/dmd/FileName.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/FileName.d	Sun Oct 10 03:48:06 2010 +0400
@@ -444,7 +444,7 @@
 			size_t len = e.ptr - name.ptr;
 			size_t extlen = ext.length;
 
-			char* s = cast(char*)malloc(len + extlen + 1);  /// !
+			char* s = cast(char*)GC.malloc(len + extlen + 1);  /// !
 			memcpy(s, name.ptr, len);
 			memcpy(s + len, ext.ptr, extlen + 1);
 			return new FileName(assumeUnique(s[0..len+extlen]));
--- a/dmd/ForeachStatement.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/ForeachStatement.d	Sun Oct 10 03:48:06 2010 +0400
@@ -653,7 +653,7 @@
 					/* Call:
 					 *	_aApply(aggr, flde)
 					 */
-					static char fntab[9][3] =
+					enum char fntab[9][3] =
 					[ "cc","cw","cd",
 					  "wc","cc","wd",
 					  "dc","dw","dd"
--- a/dmd/FuncDeclaration.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/FuncDeclaration.d	Sun Oct 10 03:48:06 2010 +0400
@@ -125,6 +125,8 @@
 
 import std.string;
 
+__gshared static int hiddenparami;    // how many we've generated so far
+
 class FuncDeclaration : Declaration
 {
     Array fthrows;			// Array of Type's of exceptions (not used)
@@ -3409,8 +3411,6 @@
 			// as the first argument
 			.type* thidden = tf.next.pointerTo().toCtype();
 			char hiddenparam[5+4+1];
-			static int hiddenparami;    // how many we've generated so far
-
 			sprintf(hiddenparam.ptr, "__HID%d".ptr, ++hiddenparami);
 			shidden = symbol_name(hiddenparam.ptr, SC.SCparameter, thidden);
 			shidden.Sflags |= SFL.SFLtrue | SFL.SFLfree;
--- a/dmd/Lexer.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/Lexer.d	Sun Oct 10 03:48:06 2010 +0400
@@ -1992,7 +1992,7 @@
 					}
 					t.len = stringbuffer.offset;
 					stringbuffer.writeByte(0);
-					void* mem = malloc(stringbuffer.offset);
+					void* mem = GC.malloc(stringbuffer.offset);
 					memcpy(mem, stringbuffer.data, stringbuffer.offset);
 					t.ustring = cast(const(char)*)mem;
 					stringPostfix(t);
@@ -2182,7 +2182,7 @@
 			error("delimited string must end in %c\"", delimright);
 		t.len = stringbuffer.offset;
 		stringbuffer.writeByte(0);
-		void* mem = malloc(stringbuffer.offset);
+		void* mem = GC.malloc(stringbuffer.offset);
 		memcpy(mem, stringbuffer.data, stringbuffer.offset);
 		t.ustring = cast(const(char)*)mem;
 		stringPostfix(t);
--- a/dmd/OutBuffer.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/OutBuffer.d	Sun Oct 10 03:48:06 2010 +0400
@@ -292,7 +292,7 @@
     string toChars()
 	{
 	   char[] s = getString();
-	   char* copy = cast(char*)malloc(s.length);
+	   char* copy = cast(char*)GC.malloc(s.length);
 	   memcpy(copy, s.ptr, s.length);
 	   return assumeUnique(copy[0..s.length]);
 
--- a/dmd/PREC.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/PREC.d	Sun Oct 10 03:48:06 2010 +0400
@@ -30,7 +30,7 @@
     PREC_primary,
 }
 
-PREC precedence[TOK.TOKMAX];
+__gshared PREC precedence[TOK.TOKMAX];
 
 import dmd.EnumUtils;
 mixin(BringToCurrentScope!(PREC));
\ No newline at end of file
--- a/dmd/StringExp.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/StringExp.d	Sun Oct 10 03:48:06 2010 +0400
@@ -855,7 +855,7 @@
 			e.Eoper = OPER.OPstring;
 static if (true) {
 			// Match MEM_PH_FREE for OPstring in ztc\el.c
-			e.EV.ss.Vstring = cast(char*)malloc((len + 1) * sz); /// !
+			e.EV.ss.Vstring = cast(char*)GC.malloc((len + 1) * sz); /// !
 			memcpy(e.EV.ss.Vstring, string_, (len + 1) * sz);
 } else {
 			e.EV.ss.Vstring = cast(char*)string_;
--- a/dmd/Util.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/Util.d	Sun Oct 10 03:48:06 2010 +0400
@@ -929,7 +929,7 @@
 	    argv.push(cast(void *)p);
 	else
 	{
-	    char *s = cast(char *)malloc(plen + 3);
+	    char *s = cast(char *)GC.malloc(plen + 3);
 	    s[0] = '-';
 	    s[1] = 'l';
 	    memcpy(s + 2, p, plen + 1);
@@ -943,7 +943,7 @@
     const char *libname = (global.params.symdebug)
 				? global.params.debuglibname
 				: global.params.defaultlibname;
-    char *buf = cast(char *)malloc(2 + strlen(libname) + 1);
+    char *buf = cast(char *)GC.malloc(2 + strlen(libname) + 1);
     strcpy(buf, "-l");
     strcpy(buf + 2, libname);
     argv.push(cast(void *)buf);		// turns into /usr/lib/libphobos2.a
@@ -1044,7 +1044,7 @@
     if (len > 255)
     {   
 		char* q;
-		static char[9] envname = "@_CMDLINE";
+		char[9] envname = "@_CMDLINE";
 
 		envname[0] = '@';
 		switch (useenv)
--- a/dmd/backend/Configv.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/backend/Configv.d	Sun Oct 10 03:48:06 2010 +0400
@@ -17,4 +17,4 @@
     int errmax;			// max error count
 }
 
-Configv configv;
\ No newline at end of file
+__gshared Configv configv;
\ No newline at end of file
--- a/dmd/backend/Util.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/backend/Util.d	Sun Oct 10 03:48:06 2010 +0400
@@ -57,7 +57,7 @@
 
 void el_setLoc(elem* e, Loc loc) {
    size_t len = loc.filename.length;
-   e.Esrcpos.Sfilename = cast(char*)malloc(len + 1);
+   e.Esrcpos.Sfilename = cast(char*)GC.malloc(len + 1);
    memcpy(e.Esrcpos.Sfilename, loc.filename.ptr, len);
    e.Esrcpos.Sfilename[len] = 0;
 	e.Esrcpos.Slinnum = loc.linnum;
--- a/dmd/backend/glue.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/backend/glue.d	Sun Oct 10 03:48:06 2010 +0400
@@ -48,7 +48,7 @@
 import std.exception;
 import std.string;
 
-string lastmname;
+__gshared string lastmname;
 
 struct Outbuffer
 {
--- a/dmd/backend/iasm.d	Sun Oct 10 03:47:23 2010 +0400
+++ b/dmd/backend/iasm.d	Sun Oct 10 03:48:06 2010 +0400
@@ -66,8 +66,8 @@
 	__gshared int BPRM;
 }
 
-const(char)*[ASMTK.ASMTKmax] apszAsmtk = [
-	"__LOCAL_SIZE",
+enum const(char)*[ASMTK.ASMTKmax] apszAsmtk = [
+	"__LOCAL_SIZE".ptr,
 	"dword".ptr,
 	"even".ptr,
 	"far".ptr,
@@ -292,9 +292,9 @@
 enum _m512 = _m224;
 enum _sti = CONSTRUCT_FLAGS( 0, _float, 0, _rsti );
 
-REG regFp =	{ "ST", 0, _st };
-
-REG[8] aregFp = [
+__gshared REG regFp =	{ "ST", 0, _st };
+
+enum REG[8] aregFp = [
 	{ "ST(0)", 0, _sti },
 	{ "ST(1)", 1, _sti },
 	{ "ST(2)", 2, _sti },
@@ -1423,7 +1423,7 @@
 
 mixin(BringToCurrentScope!(ASMERRMSGS));
 
-string[] asmerrmsgs =
+enum string[] asmerrmsgs =
 [
     "unknown operand for floating point instruction",
     "bad addr mode",
@@ -4375,7 +4375,7 @@
 		o1.ptype = d.type.toBasetype();
 }
 
-REG[63] regtab = 
+enum REG[63] regtab = 
 [
 	{"AL",	_AL,	_r8 | _al,},
 	{"AH",	_AH,	_r8,},