I've run across what I believe to be a bug in mem_malloc.

Basically, if you allocate all the memory in multiple blocks, then
free the first block you allocated, you cannot allocate a new block of
the same size.

The following code fails:

test() {
 void * ptr1
 void * cur;

 /** allocate the first block */
 ptr1 = mem_malloc(200);
 ASSERT(ptr1); /* <--- this succeeds */

 /** allocate all the remaining blocks */
 do {
   cur = mem_malloc(200);
 } while (cur);

 /** free the first block */
 mem_free(ptr1);

 /** now attempt to re-allocate the 200 bytes just freed */
 ptr1 = mem_malloc(200);
 ASSERT(ptr1);  /* <---- this FAILS */
}

I have an idea why this is failing (and a possible method to fix it),
but I wanted to make sure this wasn't already known and expected.

Thoughts?

-Tom


_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to