summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lgc.c17
-rw-r--r--lstring.c15
-rw-r--r--lstring.h3
3 files changed, 18 insertions, 17 deletions
diff --git a/lgc.c b/lgc.c
index 3bc0740b..5823cb6b 100644
--- a/lgc.c
+++ b/lgc.c
@@ -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*/
984static 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
993static l_mem atomic (lua_State *L) { 980static 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' */
diff --git a/lstring.c b/lstring.c
index 638f3dec..5af5050b 100644
--- a/lstring.c
+++ b/lstring.c
@@ -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*/
94void 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*/
93void luaS_init (lua_State *L) { 106void luaS_init (lua_State *L) {
diff --git a/lstring.h b/lstring.h
index 2b06afaf..cba3cb28 100644
--- a/lstring.h
+++ b/lstring.h
@@ -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 @@
36LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 36LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
37LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 37LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
38LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 38LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
39LUAI_FUNC void luaS_clearcache (global_State *g);
39LUAI_FUNC void luaS_init (lua_State *L); 40LUAI_FUNC void luaS_init (lua_State *L);
40LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 41LUAI_FUNC void luaS_remove (lua_State *L, TString *ts);
41LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 42LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s);