diff options
-rw-r--r-- | lgc.c | 17 | ||||
-rw-r--r-- | lstring.c | 15 | ||||
-rw-r--r-- | lstring.h | 3 |
3 files changed, 18 insertions, 17 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.203 2015/03/04 13:31:21 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.204 2015/03/04 13:51:55 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -977,19 +977,6 @@ void luaC_freeallobjects (lua_State *L) { | |||
977 | } | 977 | } |
978 | 978 | ||
979 | 979 | ||
980 | /* | ||
981 | ** Clear API string cache. (Entries cannot be empty, so fill them with | ||
982 | ** a non-collectable string.) | ||
983 | */ | ||
984 | static void clearapihash (global_State *g) { | ||
985 | int i; | ||
986 | for (i = 0; i < STRCACHE_SIZE; i++) { | ||
987 | if (iswhite(g->strcache[i])) /* will entry be collected? */ | ||
988 | g->strcache[i] = g->memerrmsg; /* replace it with something fixed */ | ||
989 | } | ||
990 | } | ||
991 | |||
992 | |||
993 | static l_mem atomic (lua_State *L) { | 980 | static l_mem atomic (lua_State *L) { |
994 | global_State *g = G(L); | 981 | global_State *g = G(L); |
995 | l_mem work; | 982 | l_mem work; |
@@ -1030,7 +1017,7 @@ static l_mem atomic (lua_State *L) { | |||
1030 | /* clear values from resurrected weak tables */ | 1017 | /* clear values from resurrected weak tables */ |
1031 | clearvalues(g, g->weak, origweak); | 1018 | clearvalues(g, g->weak, origweak); |
1032 | clearvalues(g, g->allweak, origall); | 1019 | clearvalues(g, g->allweak, origall); |
1033 | clearapihash(g); | 1020 | luaS_clearcache(g); |
1034 | g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ | 1021 | g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ |
1035 | work += g->GCmemtrav; /* complete counting */ | 1022 | work += g->GCmemtrav; /* complete counting */ |
1036 | return work; /* estimate of memory marked by 'atomic' */ | 1023 | return work; /* estimate of memory marked by 'atomic' */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 2.46 2015/01/16 16:54:37 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 2.47 2015/03/04 13:31:21 roberto Exp roberto $ |
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 | */ |
@@ -88,6 +88,19 @@ void luaS_resize (lua_State *L, int newsize) { | |||
88 | 88 | ||
89 | 89 | ||
90 | /* | 90 | /* |
91 | ** Clear API string cache. (Entries cannot be empty, so fill them with | ||
92 | ** a non-collectable string.) | ||
93 | */ | ||
94 | void luaS_clearcache (global_State *g) { | ||
95 | int i; | ||
96 | for (i = 0; i < STRCACHE_SIZE; i++) { | ||
97 | if (iswhite(g->strcache[i])) /* will entry be collected? */ | ||
98 | g->strcache[i] = g->memerrmsg; /* replace it with something fixed */ | ||
99 | } | ||
100 | } | ||
101 | |||
102 | |||
103 | /* | ||
91 | ** Initialize the string table and the string cache | 104 | ** Initialize the string table and the string cache |
92 | */ | 105 | */ |
93 | void luaS_init (lua_State *L) { | 106 | void luaS_init (lua_State *L) { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.h,v 1.57 2015/01/16 16:54:37 roberto Exp roberto $ | 2 | ** $Id: lstring.h,v 1.58 2015/03/04 13:31:21 roberto Exp roberto $ |
3 | ** String table (keep all strings handled by Lua) | 3 | ** String table (keep all strings handled by Lua) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -36,6 +36,7 @@ | |||
36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); | 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); |
37 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); | 37 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); |
38 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); | 38 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); |
39 | LUAI_FUNC void luaS_clearcache (global_State *g); | ||
39 | LUAI_FUNC void luaS_init (lua_State *L); | 40 | LUAI_FUNC void luaS_init (lua_State *L); |
40 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); | 41 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); |
41 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); | 42 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); |