[En-Nut-Discussion] NutHeapAlloc Error?
Timothy M. De Baillie
debaillie at ciholas.com
Mon Oct 13 21:06:59 CEST 2008
I'm trying to trace down a bug on a system that has REALLY low memory
and has lots and lots of mallocs. So this may not really be a problem,
but I thought I would see what others thought.
in the OS, os/heap.c,
~~~ OS CUT ~~~
void *NutHeapAlloc(size_t size)
{
......
if (size >= available) {
#ifdef NUTDEBUG
if (__heap_trf)
fputs("MEMOVR\n", __heap_trs);
#endif
return 0;
}
/*
* We need additional space in front of the allocated memory
* block to store its size. If this is still less than the
* space required by a free node, increase it.
*/
if ((size += MEMOVHD) < sizeof(HEAPNODE))
size = sizeof(HEAPNODE);
~~~ OS CUT ~~~
Should the check "if(size >= available)" not happen after the last two
lines?
From what I read, if you request 11 bytes and had exactly 11 bytes
available, then you would cause a memory wrap of some sort.
Thanks in advanced,
Tim
More information about the En-Nut-Discussion
mailing list