Mercurial > projects > ddmd
comparison dmd/backend/Util.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 | 10317f0c89a5 |
children | 2cc604139636 |
comparison
equal
deleted
inserted
replaced
4:d706d958e4e8 | 5:63623152e82a |
---|---|
17 import dmd.backend.struct_t; | 17 import dmd.backend.struct_t; |
18 import dmd.backend.BC; | 18 import dmd.backend.BC; |
19 import dmd.backend.code; | 19 import dmd.backend.code; |
20 | 20 |
21 import std.string; | 21 import std.string; |
22 import core.stdc.stdlib; | |
23 import core.stdc.string; | |
22 | 24 |
23 alias ubyte mangle_t; | 25 alias ubyte mangle_t; |
24 | 26 |
25 alias SC enum_SC; | 27 alias SC enum_SC; |
26 alias uint SYMFLGS; | 28 alias uint SYMFLGS; |
49 | 51 |
50 alias uint tym_t; // data type big enough for type masks | 52 alias uint tym_t; // data type big enough for type masks |
51 alias elem* elem_p; // data type big enough for type masks | 53 alias elem* elem_p; // data type big enough for type masks |
52 | 54 |
53 void el_setLoc(elem* e, Loc loc) { | 55 void el_setLoc(elem* e, Loc loc) { |
54 e.Esrcpos.Sfilename = cast(char*)toStringz(loc.filename); | 56 size_t len = loc.filename.length; |
57 e.Esrcpos.Sfilename = cast(char*)malloc(len + 1); | |
58 memcpy(e.Esrcpos.Sfilename, loc.filename.ptr, len); | |
59 e.Esrcpos.Sfilename[len] = 0; | |
55 e.Esrcpos.Slinnum = loc.linnum; | 60 e.Esrcpos.Slinnum = loc.linnum; |
56 } | 61 } |
57 | 62 |
58 void elem_setLoc(elem* e, Loc loc) { | 63 void elem_setLoc(elem* e, Loc loc) { |
59 return el_setLoc(e, loc); | 64 return el_setLoc(e, loc); |