MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / getdetails

Function getdetails

extlibs/lua/src/lstrlib.c:1490–1508  ·  view source on GitHub ↗

** Read, classify, and fill other details about the next option. ** 'psize' is filled with option's size, 'notoalign' with its ** alignment requirements. ** Local variable 'size' gets the size to be aligned. (Kpadal option ** always gets its full alignment, other options are limited by ** the maximum alignment ('maxalign'). Kchar option needs no alignment ** despite its size. */

Source from the content-addressed store, hash-verified

1488** despite its size.
1489*/
1490static KOption getdetails (Header *h, size_t totalsize,
1491 const char **fmt, int *psize, int *ntoalign) {
1492 KOption opt = getoption(h, fmt, psize);
1493 int align = *psize; /* usually, alignment follows size */
1494 if (opt == Kpaddalign) { /* 'X' gets alignment from following option */
1495 if (**fmt == '\0' || getoption(h, fmt, &align) == Kchar || align == 0)
1496 luaL_argerror(h->L, 1, "invalid next option for option 'X'");
1497 }
1498 if (align <= 1 || opt == Kchar) /* need no alignment? */
1499 *ntoalign = 0;
1500 else {
1501 if (align > h->maxalign) /* enforce maximum alignment */
1502 align = h->maxalign;
1503 if ((align & (align - 1)) != 0) /* is 'align' not a power of 2? */
1504 luaL_argerror(h->L, 1, "format asks for alignment not power of 2");
1505 *ntoalign = (align - (int)(totalsize & (align - 1))) & (align - 1);
1506 }
1507 return opt;
1508}
1509
1510
1511/*

Callers 3

str_packFunction · 0.85
str_packsizeFunction · 0.85
str_unpackFunction · 0.85

Calls 2

getoptionFunction · 0.85
luaL_argerrorFunction · 0.85

Tested by

no test coverage detected