In C, typedef K represents a k object. It is a pointer to a
struct containing the following fields + content specific data:
c ref count
n number of items
t type of the object
These can be directly accessed from C code but should never be
directly modified. Object content should only be accessed
or modified through macros described below.
A k object can be of the following types (the first column
shows the value in t field).
K KK(K)
KK() takes a general list and retuns a ptr to an array of
objects.
#define KK(x) ((K*)((x)->k))
KK(d)[0] = gsk("foo", gi(12));
Z I ns = 0, sd = 0;
// Z S sdup(S s){R strdupn(s,strlen(s));} //using this because "strdup" uses
// [used] dynamically linked malloc which fails with our static free
Z S sdupI(S s) {
I k;
S d = alloc(NSLOTS * sizeof(I) + (k = strlen(s)) + 1);
if (!d)
R 0;
ns++;
sd = 1;
d += NSLOTS * sizeof(I);
d[k] = 0;
R memcpy(d, s, k);
}