In sub-allocation of SGI STL allocator, there are 16 free-lists which separately manage small blocks of size 8,16,….,128. The structure of the free-lists’ node is:
union obj{
union obj *free_list_link;
char client_data[1];
}
My question is : why it is designed like this? What is the member client_data used for?
This is a common design pattern.
client_data[] is really 8, 16, .. 128 bytes.
If you look at where an obj is allocated, it might look like
malloc( sizeof(obj) + 128 )
for a 128 byte block.