News for hackers. Stuff that matters.
Re:A Database Without Dynamic Memory Allocation by ericbarrett on Thursday October 13, 2022 @02:10PM (#33194466)
I was curious about that too :) My guess is 16 items (edit: OP says 12) but I'm not an embedded developer, and I'm sure it's hardware-specific.

The approach I've seen for larger fixed-sized tables is a free list: when the table is allocated, also initialize an array of the slot numbers, with an associated length index. To allocate, pop the last slot # off the array and decrement the length index. To free, push the slot # onto the end of the array and increment the length index. Checking for a free slot is then just testing for length index > 0.

Re:A Database Without Dynamic Memory Allocation by aidenn0 on Thursday October 13, 2022 @03:22PM (#33195344)
Yeah, a stack of free indexes is good. In the rare case of "lots of indexes, but little (extra) memory" a bitmap can be good because it's 1 bit per index rather than ⌈log2(N)⌉ bits per index and has a constant factor speed up equal to the word-size of the architecture.