summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-01-05 12:30:49 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-01-05 12:30:49 +0000
commit6663349b8883039f22478e485ceebfe7711de84e (patch)
tree6d679637f4ec376d3c310cdef302bd951b06090b
parent1113f1a9304ef42586921f77e0eada2db25b19ea (diff)
downloaddrakx-6663349b8883039f22478e485ceebfe7711de84e.tar
drakx-6663349b8883039f22478e485ceebfe7711de84e.tar.gz
drakx-6663349b8883039f22478e485ceebfe7711de84e.tar.bz2
drakx-6663349b8883039f22478e485ceebfe7711de84e.tar.xz
drakx-6663349b8883039f22478e485ceebfe7711de84e.zip
fix malloc from latest dietlibc version
-rw-r--r--mdk-stage1/dietlibc/lib/alloc.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/mdk-stage1/dietlibc/lib/alloc.c b/mdk-stage1/dietlibc/lib/alloc.c
index 7e3bedc74..27b6838df 100644
--- a/mdk-stage1/dietlibc/lib/alloc.c
+++ b/mdk-stage1/dietlibc/lib/alloc.c
@@ -148,10 +148,18 @@ void *malloc(size_t size)
else
{
alloc_head *tmp=(alloc_head*)(((char*)p)+need);
-
- prev->ptr=tmp;
- tmp->ptr=p->ptr;
- tmp->size=p->size-need; /* remaining size */
+ if ((p->size-need)<sizeof(alloc_head))
+ { /* work around: if there is not enough space for freelist head.
+ * this waste some bytes ( < sizeof(alloc_head) ) */
+ need=p->size;
+ prev->ptr=p->ptr; /* relink freelist */
+ }
+ else
+ {
+ prev->ptr=tmp;
+ tmp->ptr=p->ptr;
+ tmp->size=p->size-need; /* remaining size */
+ }
p->size=need; /* set size */
}