MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / putinteger

Function putinteger

deps/lua/src/lua_struct.c:169–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167
168
169static void putinteger (lua_State *L, luaL_Buffer *b, int arg, int endian,
170 int size) {
171 lua_Number n = luaL_checknumber(L, arg);
172 Uinttype value;
173 char buff[MAXINTSIZE];
174 if (n < 0)
175 value = (Uinttype)(Inttype)n;
176 else
177 value = (Uinttype)n;
178 if (endian == LITTLE) {
179 int i;
180 for (i = 0; i < size; i++) {
181 buff[i] = (value & 0xff);
182 value >>= 8;
183 }
184 }
185 else {
186 int i;
187 for (i = size - 1; i >= 0; i--) {
188 buff[i] = (value & 0xff);
189 value >>= 8;
190 }
191 }
192 luaL_addlstring(b, buff, size);
193}
194
195
196static void correctbytes (char *b, int size, int endian) {

Callers 1

b_packFunction · 0.85

Calls 2

luaL_checknumberFunction · 0.85
luaL_addlstringFunction · 0.85

Tested by

no test coverage detected