MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / str_packsize

Function str_packsize

lib/lua/src/lstrlib.c:1700–1717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1698
1699
1700static int str_packsize (lua_State *L) {
1701 Header h;
1702 const char *fmt = luaL_checkstring(L, 1); /* format string */
1703 size_t totalsize = 0; /* accumulate total size of result */
1704 initheader(L, &h);
1705 while (*fmt != '\0') {
1706 int size, ntoalign;
1707 KOption opt = getdetails(&h, totalsize, &fmt, &size, &ntoalign);
1708 luaL_argcheck(L, opt != Kstring && opt != Kzstr, 1,
1709 "variable-length format");
1710 size += ntoalign; /* total space used by option */
1711 luaL_argcheck(L, totalsize <= MAXSIZE - size, 1,
1712 "format result too large");
1713 totalsize += size;
1714 }
1715 lua_pushinteger(L, (lua_Integer)totalsize);
1716 return 1;
1717}
1718
1719
1720/*

Callers

nothing calls this directly

Calls 3

initheaderFunction · 0.85
getdetailsFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected