Wouldn't a sparse matrix implementation of this be a better thing.
I don't have a link. But you'd initialize doing something like this:
uint8_t data[256];
free_list = 0;
for ( i = 1; i < 256; i++ )
{
// Add Each byte to the free list.
data[i] = free_list;
free_list = i;
}
Finding a free entry would be something like:
if ( free_list != 0 )
{
uint8_t *avail = &data[free_list];
free_list = *avail;
*avail = 0;
return avail;
}
and freeing would be something like this:
index = freePtr - data;
data[index] = free_list;
free_list = index;