From b436ed58a3416c2e1936bdce880ac09925401a87 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 25 Mar 2015 10:42:19 -0300 Subject: 'clearapihash' -> 'luaS_clearcache' and moved to 'lstring.c' (which keeps all code related to this cache) --- lstring.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lstring.c') diff --git a/lstring.c b/lstring.c index 638f3dec..5af5050b 100644 --- a/lstring.c +++ b/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 2.46 2015/01/16 16:54:37 roberto Exp roberto $ +** $Id: lstring.c,v 2.47 2015/03/04 13:31:21 roberto Exp roberto $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -87,6 +87,19 @@ void luaS_resize (lua_State *L, int newsize) { } +/* +** Clear API string cache. (Entries cannot be empty, so fill them with +** a non-collectable string.) +*/ +void luaS_clearcache (global_State *g) { + int i; + for (i = 0; i < STRCACHE_SIZE; i++) { + if (iswhite(g->strcache[i])) /* will entry be collected? */ + g->strcache[i] = g->memerrmsg; /* replace it with something fixed */ + } +} + + /* ** Initialize the string table and the string cache */ -- cgit v1.2.3-55-g6feb