Hi guys,
I thought of a solution for the 10 / 50 / 200 Bytes problem.
How about this:
1. 10-byte blocks could be allocated on every 10-byte step - i.e. addresses 0, 10, 20, 30, 40, 50, 60, .....
2. 50-byte blocks could be allocated on every 50-byte step - i.e. addresses 0, 50, 100, 150, 200, 250, ...
3. 200-byte blocks could be allocated on every 200-byte step - i.e. addresses 0, 200, 400
struct freelist
{
struct freelist *pprev, *pnext;
} freelist10, freelist50, freelist200;
4. 3 lists will be initialized at first, with all free spaces.
5. each list will point on the available block -> therefore it'd take O(1).
The disadvantages here are:
1. that if say addresses 10 to 60 are available, the algorithm will not count it as an available space for a 50-byte block.
2. the header will be 3 times bigger.
Is there a better way?