Pretty long, as C quite obviously isn't well-suited to manipulating lists of lists. Dependent on certain behavior; running on some platforms requires changing
short (for +2 bytes), due to
wchar_t being UTF-16 rather than UTF-32. Should work on Linux as-is.
Takes in a pointer to the first element of the input array, the length of the array, and a pointer to the variable in which the pointer to output will be stored. Produces a list of lists such that the first integer in the linear array stores the number of sub-lists. Sub-lists start with the number of elements, and are stored in memory in a contiguous manner.
Try it online!
p(r,e,f,i,x) int**r,*e,*x; // Function p(), where r is a pointer to the output variable,
// e is a pointer to the input location and f is the size of
// the input.
x=*r=malloc(4-++f*~f*2); // Allocate 4*(x+1)*(x+2)/2+4 bytes of memory.
// This is the exact amount of memory needed.
*x++=f; // Store n+1 (number of sub-lists) in the first four bytes.
for(i=0;i<f;x+=++i) // Iterate over [0, n]->i and
// increment the pointer to x by i+1 every iteration.
wmemcpy(x+1,e,*x=i); // Set first element at location pointed to by x to i,
// then copy i of either 2 or 4 byte elements, depending on
// the system wchar implementation, to location pointed to
// by x+1.