[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] mem_malloc bug
From: |
Tom Hennen |
Subject: |
[lwip-users] mem_malloc bug |
Date: |
Tue, 3 Oct 2006 16:16:12 -0400 |
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] mem_malloc bug,
Tom Hennen <=