aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-11-09 17:05:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-11-09 17:05:42 -0300
commit024f9064f1b43758eb36aba52547edc0312bf4ba (patch)
tree9d8609112058e885196a581f0736fbdd94f7f94d /lapi.c
parent7f4906f565ab9f8b1125107a3abae3d759f3ecf2 (diff)
downloadlua-024f9064f1b43758eb36aba52547edc0312bf4ba.tar.gz
lua-024f9064f1b43758eb36aba52547edc0312bf4ba.tar.bz2
lua-024f9064f1b43758eb36aba52547edc0312bf4ba.zip
External strings
Strings can use external buffers to store their contents.
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lapi.c b/lapi.c
index 34b335fd..2aaa6505 100644
--- a/lapi.c
+++ b/lapi.c
@@ -535,6 +535,20 @@ LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) {
535} 535}
536 536
537 537
538LUA_API const char *lua_pushextlstring (lua_State *L,
539 const char *s, size_t len, lua_Alloc falloc, void *ud) {
540 TString *ts;
541 lua_lock(L);
542 api_check(L, s[len] == '\0', "string not ending with zero");
543 ts = luaS_newextlstr (L, s, len, falloc, ud);
544 setsvalue2s(L, L->top.p, ts);
545 api_incr_top(L);
546 luaC_checkGC(L);
547 lua_unlock(L);
548 return getstr(ts);
549}
550
551
538LUA_API const char *lua_pushstring (lua_State *L, const char *s) { 552LUA_API const char *lua_pushstring (lua_State *L, const char *s) {
539 lua_lock(L); 553 lua_lock(L);
540 if (s == NULL) 554 if (s == NULL)