This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
dlmalloc package realloc issue(?)
- From: Mike Jastrebtsoff <mike at eltronix dot ru>
- To: ecos-discuss at sources dot redhat dot com
- Date: Sun, 24 Oct 2004 23:23:28 +0700
- Subject: [ECOS] dlmalloc package realloc issue(?)
- Organization: Eltronix.ru
- Reply-to: Mike Jastrebtsoff <mike at eltronix dot ru>
Hello, All.
It seems I've found the problem in Doug Lea's malloc implementation.
When calling realloc, algorithm should do the following(Cyg_Mempool_dlmalloc_Implementation::resize_alloc)
:
1. Try expand reallocation block to forward.
2. Try shifting it to backwards.
3. If none of the above mentioned methods work out,
it should make malloc(new), memcpy(new, old, oldsize), free(old)
But it doesn't do that:
Cyg_Mempool_dlmalloc_Implementation::resize_alloc( ...)
{
...
if (!prev_inuse(oldp)) // <-
{
...
}
// couldn't resize the allocation any direction, so return failure
MALLOC_UNLOCK;
return NULL;
...
}
i.e if previous chunk is used,
algorithm returns NULL.
--
Regards,
Mike
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss