MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / LoadConstants

Function LoadConstants

src/Chain/libraries/glua/lundump.cpp:131–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129// 500M
130const int g_constantslimit = 1024 * 1024 * 500;
131static bool LoadConstants(LoadState *S, Proto *f) {
132 int i;
133 int n = LoadInt(S);
134 if (n > g_constantslimit)
135 {
136 return false;
137 }
138
139 f->k = luaM_newvector(S->L, n, TValue);
140 f->sizek = n;
141 for (i = 0; i < n; i++)
142 setnilvalue(&f->k[i]);
143 for (i = 0; i < n; i++) {
144 TValue *o = &f->k[i];
145 int t = LoadByte(S);
146 switch (t) {
147 case LUA_TNIL:
148 setnilvalue(o);
149 break;
150 case LUA_TBOOLEAN:
151 setbvalue(o, LoadByte(S));
152 break;
153 case LUA_TNUMFLT:
154 setfltvalue(o, LoadNumber(S));
155 break;
156 case LUA_TNUMINT:
157 setivalue(o, LoadInteger(S));
158 break;
159 case LUA_TSHRSTR:
160 case LUA_TLNGSTR:
161 setsvalue2n(S->L, o, LoadString(S));
162 break;
163 default:
164 lua_assert(0);
165 }
166 }
167 return true;
168}
169
170// 500M
171static bool LoadProtos(LoadState *S, Proto *f) {

Callers 1

LoadFunctionFunction · 0.85

Calls 5

LoadIntFunction · 0.85
LoadByteFunction · 0.85
LoadNumberFunction · 0.85
LoadIntegerFunction · 0.85
LoadStringFunction · 0.85

Tested by

no test coverage detected