MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / luaL_prepbuffsize

Function luaL_prepbuffsize

libraries/AP_Scripting/lua/src/lauxlib.c:508–528  ·  view source on GitHub ↗

** returns a pointer to a free area with at least 'sz' bytes */

Source from the content-addressed store, hash-verified

506** returns a pointer to a free area with at least 'sz' bytes
507*/
508LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) {
509 lua_State *L = B->L;
510 if (B->size - B->n < sz) { /* not enough space? */
511 char *newbuff;
512 size_t newsize = B->size * 2; /* double buffer size */
513 if (newsize - B->n < sz) /* not big enough? */
514 newsize = B->n + sz;
515 if (newsize < B->n || newsize - B->n < sz)
516 luaL_error(L, "buffer too large");
517 /* create larger buffer */
518 if (buffonstack(B))
519 newbuff = (char *)resizebox(L, -1, newsize);
520 else { /* no buffer yet */
521 newbuff = (char *)newbox(L, newsize);
522 memcpy(newbuff, B->b, B->n * sizeof(char)); /* copy original content */
523 }
524 B->b = newbuff;
525 B->size = newsize;
526 }
527 return &B->b[B->n];
528}
529
530
531LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {

Callers 8

addliteralFunction · 0.85
str_formatFunction · 0.85
packintFunction · 0.85
str_packFunction · 0.85
luaL_addlstringFunction · 0.85
luaL_buffinitsizeFunction · 0.85
os_dateFunction · 0.85
read_charsFunction · 0.85

Calls 4

luaL_errorFunction · 0.85
resizeboxFunction · 0.85
newboxFunction · 0.85
memcpyFunction · 0.85

Tested by

no test coverage detected