Showing the changes to src/lstring.c (1 of 45 files). Show all
Unified · Split
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstring.c,v 2.38 2014/03/19 18:51:42 roberto Exp $ | 2 | ** $Id: lstring.c,v 2.40 2014/06/18 22:59:29 roberto Exp $ |
| 3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -90,9 +90,11 @@ void luaS_resize (lua_State *L, int newsize) { · 84 unmodified lines | |||
| 90 | static TString *createstrobj (lua_State *L, const char *str, size_t l, | 90 | static TString *createstrobj (lua_State *L, const char *str, size_t l, |
| 91 | int tag, unsigned int h) { | 91 | int tag, unsigned int h) { |
| 92 | TString *ts; | 92 | TString *ts; |
| 93 | GCObject *o; | ||
| 93 | size_t totalsize; /* total size of TString object */ | 94 | size_t totalsize; /* total size of TString object */ |
| 94 | totalsize = sizeof(TString) + ((l + 1) * sizeof(char)); | 95 | totalsize = sizeof(TString) + ((l + 1) * sizeof(char)); |
| 95 | ts = &luaC_newobj(L, tag, totalsize)->ts; | 96 | o = luaC_newobj(L, tag, totalsize); |
| 97 | ts = rawgco2ts(o); | ||
| 96 | ts->tsv.len = l; | 98 | ts->tsv.len = l; |
| 97 | ts->tsv.hash = h; | 99 | ts->tsv.hash = h; |
| 98 | ts->tsv.extra = 0; | 100 | ts->tsv.extra = 0; |
| @@ -102,7 +104,7 @@ static TString *createstrobj (lua_State *L, const char *str, size_t l, · 3 unmodified lines | |||
| 102 | } | 104 | } |
| 103 | 105 | ||
| 104 | 106 | ||
| 105 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts) { | 107 | void luaS_remove (lua_State *L, TString *ts) { |
| 106 | stringtable *tb = &G(L)->strt; | 108 | stringtable *tb = &G(L)->strt; |
| 107 | TString **p = &tb->hash[lmod(ts->tsv.hash, tb->size)]; | 109 | TString **p = &tb->hash[lmod(ts->tsv.hash, tb->size)]; |
| 108 | while (*p != ts) /* find previous element */ | 110 | while (*p != ts) /* find previous element */ |
| @@ -165,9 +167,11 @@ TString *luaS_new (lua_State *L, const char *str) { · 56 unmodified lines | |||
| 165 | 167 | ||
| 166 | Udata *luaS_newudata (lua_State *L, size_t s) { | 168 | Udata *luaS_newudata (lua_State *L, size_t s) { |
| 167 | Udata *u; | 169 | Udata *u; |
| 170 | GCObject *o; | ||
| 168 | if (s > MAX_SIZE - sizeof(Udata)) | 171 | if (s > MAX_SIZE - sizeof(Udata)) |
| 169 | luaM_toobig(L); | 172 | luaM_toobig(L); |
| 170 | u = &luaC_newobj(L, LUA_TUSERDATA, sizeof(Udata) + s)->u; | 173 | o = luaC_newobj(L, LUA_TUSERDATA, sizeof(Udata) + s); |
| 174 | u = rawgco2u(o); | ||
| 171 | u->uv.len = s; | 175 | u->uv.len = s; |
| 172 | u->uv.metatable = NULL; | 176 | u->uv.metatable = NULL; |
| 173 | setuservalue(L, u, luaO_nilobject); | 177 | setuservalue(L, u, luaO_nilobject); |