jj2007: I want to get back to our discussion about a circular buffer.
Have you inspected the pool example (pool.zip) above?
I've had a look. From what I see (and apologies if my eyes are not very good at understanding C
)...
void *PoolMalloc(POOL P, size_t n)
..
ptr = malloc(n);... you are using malloc for every slot. This is different from my MasmBasic pool, which allocates one 640000 bytes buffer from which every user picks the next available slot until the end is reached, and at this point the next available one is slot #1 again. And previous content gets merciless discarded.
Your version, if I understand it correctly, provides permanent slots, but it uses malloc for each slot. That is more flexible but malloc is slow, of course.
My version is blazing fast for many small allocations (say: 10-20 cycles to get a pointer to an empty buffer) but it is naturally limited to 1. small buffers up to 640/4kB, 2. to allocations that are temporary, e.g. the buffer for a
Print Str$(n), " allocations", CrLf$, "are the limit"Once it's printed, you don't need it any more.
Similar, you can use
Let MyString=Str$(n)+" allocations"+CrLf$+"are the limit"and again, Str$() would use a temporary slot in the circular buffer. But MyString is a permanent heapalloc'ed slot.
But I don't want to advertise anything here. What are your intentions, what is your philosophy?