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

Function mp_encode_array

deps/lua/src/lua_cmsgpack.c:293–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293void mp_encode_array(lua_State *L, mp_buf *buf, int64_t n) {
294 unsigned char b[5];
295 int enclen;
296
297 if (n <= 15) {
298 b[0] = 0x90 | (n & 0xf); /* fix array */
299 enclen = 1;
300 } else if (n <= 65535) {
301 b[0] = 0xdc; /* array 16 */
302 b[1] = (n & 0xff00) >> 8;
303 b[2] = n & 0xff;
304 enclen = 3;
305 } else {
306 b[0] = 0xdd; /* array 32 */
307 b[1] = (n & 0xff000000) >> 24;
308 b[2] = (n & 0xff0000) >> 16;
309 b[3] = (n & 0xff00) >> 8;
310 b[4] = n & 0xff;
311 enclen = 5;
312 }
313 mp_buf_append(L,buf,b,enclen);
314}
315
316void mp_encode_map(lua_State *L, mp_buf *buf, int64_t n) {
317 unsigned char b[5];

Callers 1

Calls 1

mp_buf_appendFunction · 0.85

Tested by

no test coverage detected