mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
add api lua_sharestring
This commit is contained in:
@@ -1049,6 +1049,18 @@ LUA_API void lua_sharefunction (lua_State *L, int index) {
|
||||
luaF_shareproto(f->p);
|
||||
}
|
||||
|
||||
LUA_API void lua_sharestring (lua_State *L, int index) {
|
||||
const char *str = lua_tostring(L, index);
|
||||
if (str == NULL)
|
||||
luaG_runerror(L, "need a string to share");
|
||||
|
||||
TString *ts = (TString *)(str - sizeof(UTString));
|
||||
if(ts->tt == LUA_TLNGSTR)
|
||||
makeshared(ts);
|
||||
else
|
||||
luaS_fix(G(L), ts);
|
||||
}
|
||||
|
||||
LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip) {
|
||||
int status;
|
||||
TValue *o;
|
||||
|
||||
@@ -235,6 +235,7 @@ LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
|
||||
LUA_API int (lua_pushthread) (lua_State *L);
|
||||
LUA_API void (lua_clonefunction) (lua_State *L, const void * fp);
|
||||
LUA_API void (lua_sharefunction) (lua_State *L, int index);
|
||||
LUA_API void (lua_sharestring) (lua_State *L, int index);
|
||||
|
||||
/*
|
||||
** get functions (Lua -> stack)
|
||||
|
||||
Reference in New Issue
Block a user