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

Function getinteger

deps/lua/src/lua_struct.c:266–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264
265
266static lua_Number getinteger (const char *buff, int endian,
267 int issigned, int size) {
268 Uinttype l = 0;
269 int i;
270 if (endian == BIG) {
271 for (i = 0; i < size; i++) {
272 l <<= 8;
273 l |= (Uinttype)(unsigned char)buff[i];
274 }
275 }
276 else {
277 for (i = size - 1; i >= 0; i--) {
278 l <<= 8;
279 l |= (Uinttype)(unsigned char)buff[i];
280 }
281 }
282 if (!issigned)
283 return (lua_Number)l;
284 else { /* signed format */
285 Uinttype mask = (Uinttype)(~((Uinttype)0)) << (size*8 - 1);
286 if (l & mask) /* negative value? */
287 l |= mask; /* signal extension */
288 return (lua_Number)(Inttype)l;
289 }
290}
291
292
293static int b_unpack (lua_State *L) {

Callers 1

b_unpackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected