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

Function mp_encode_map

deps/lua/src/lua_cmsgpack.c:316–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316void mp_encode_map(lua_State *L, mp_buf *buf, int64_t n) {
317 unsigned char b[5];
318 int enclen;
319
320 if (n <= 15) {
321 b[0] = 0x80 | (n & 0xf); /* fix map */
322 enclen = 1;
323 } else if (n <= 65535) {
324 b[0] = 0xde; /* map 16 */
325 b[1] = (n & 0xff00) >> 8;
326 b[2] = n & 0xff;
327 enclen = 3;
328 } else {
329 b[0] = 0xdf; /* map 32 */
330 b[1] = (n & 0xff000000) >> 24;
331 b[2] = (n & 0xff0000) >> 16;
332 b[3] = (n & 0xff00) >> 8;
333 b[4] = n & 0xff;
334 enclen = 5;
335 }
336 mp_buf_append(L,buf,b,enclen);
337}
338
339/* --------------------------- Lua types encoding --------------------------- */
340

Callers 1

Calls 1

mp_buf_appendFunction · 0.85

Tested by

no test coverage detected