www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/02/20/11:42:22

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
Message-Id: <10202201642.AA14552@clio.rice.edu>
Subject: Re: Malloc/free DJGPP code
To: djgpp-workers AT delorie DOT com
Date: Wed, 20 Feb 2002 10:42:28 -0600 (CST)
In-Reply-To: <3C734B2D.F82A42FB@yahoo.com> from "CBFalconer" at Feb 20, 2002 02:07:25 AM
X-Mailer: ELM [version 2.5 PL2]
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> > I posted both; little feedback on which should be committed.  But it's
> > important that the block overhead be a factor of the alignment or you
> > will almost never merge blocks.
> 
> Important to know.  I would suggest always requesting at least
> ALIGN more than needed, so that an unexpected sbrk can be
> truncated.  

sbrk() will return the next block at the end of the memory you
previously requested - so if you don't align the "end" of your
request also you mess up your next request.  You can't leave spare
bytes since that prevents block merges.  The patches provided both
fix this problem and force alignment per the ALIGN value.

> How does my proposal for matching the unclean linkages look,
> hopefully by just matching the offset of the size component?

If we store the free list pointers in the blocks also (which I
believe is the crux of your fix) we would need the header to be
a factor of 8 bytes in size.  So the block header changes from 
8 bytes to 16 bytes.  The extra size (unfortunately) will break
a lot of internal malloc stuff unless it's also re-written.

Since the header would then be larger than the smallest block there may
also be more check code needed; the minimum allocation might also
need to increase to 16 bytes?

> I gather ALIGN = 8 is needed.  I had assumed 4 from the action of
> the present system.

ALIGN is currently defined as 8; the code aligns on 8 byte boundaries
today if sbrk() returns 8 byte alignment - which it didn't always -
which is what we were discussing last week.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019