MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / loadStringN

Function loadStringN

3rd/lua-5.4.3/src/lundump.c:110–130  ·  view source on GitHub ↗

** Load a nullable string into prototype 'p'. */

Source from the content-addressed store, hash-verified

108** Load a nullable string into prototype 'p'.
109*/
110static TString *loadStringN (LoadState *S, Proto *p) {
111 lua_State *L = S->L;
112 TString *ts;
113 size_t size = loadSize(S);
114 if (size == 0) /* no string? */
115 return NULL;
116 else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */
117 char buff[LUAI_MAXSHORTLEN];
118 loadVector(S, buff, size); /* load string into buffer */
119 ts = luaS_newlstr(L, buff, size); /* create string */
120 }
121 else { /* long string */
122 ts = luaS_createlngstrobj(L, size); /* create string */
123 setsvalue2s(L, L->top, ts); /* anchor it ('loadVector' can GC) */
124 luaD_inctop(L);
125 loadVector(S, getstr(ts), size); /* load directly in final place */
126 L->top--; /* pop string */
127 }
128 luaC_objbarrier(L, p, ts);
129 return ts;
130}
131
132
133/*

Callers 3

loadStringFunction · 0.85
loadDebugFunction · 0.85
loadFunctionFunction · 0.85

Calls 4

loadSizeFunction · 0.85
luaS_newlstrFunction · 0.85
luaS_createlngstrobjFunction · 0.85
luaD_inctopFunction · 0.85

Tested by

no test coverage detected