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

Function mp_buf_append

deps/lua/src/lua_cmsgpack.c:118–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118void mp_buf_append(lua_State *L, mp_buf *buf, const unsigned char *s, size_t len) {
119 if (buf->free < len) {
120 size_t newsize = (buf->len+len)*2;
121
122 buf->b = (unsigned char*)mp_realloc(L, buf->b, buf->len + buf->free, newsize);
123 buf->free = newsize - buf->len;
124 }
125 memcpy(buf->b+buf->len,s,len);
126 buf->len += len;
127 buf->free -= len;
128}
129
130void mp_buf_free(lua_State *L, mp_buf *buf) {
131 mp_realloc(L, buf->b, buf->len + buf->free, 0); /* realloc to 0 = free */

Callers 7

mp_encode_bytesFunction · 0.85
mp_encode_doubleFunction · 0.85
mp_encode_intFunction · 0.85
mp_encode_arrayFunction · 0.85
mp_encode_mapFunction · 0.85
mp_encode_lua_boolFunction · 0.85
mp_encode_lua_nullFunction · 0.85

Calls 1

mp_reallocFunction · 0.85

Tested by

no test coverage detected