diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2001-01-05 12:30:49 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2001-01-05 12:30:49 +0000 |
commit | 6663349b8883039f22478e485ceebfe7711de84e (patch) | |
tree | 6d679637f4ec376d3c310cdef302bd951b06090b | |
parent | 1113f1a9304ef42586921f77e0eada2db25b19ea (diff) | |
download | drakx-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.c | 16 |
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 */ } |