www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/02/12/12:03:45

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: <10202121703.AA17270@clio.rice.edu>
Subject: Re: Alignment problem
To: eliz AT is DOT elta DOT co DOT il (Eli Zaretskii)
Date: Tue, 12 Feb 2002 11:03:50 -0600 (CST)
Cc: djgpp-workers AT delorie DOT com, rudd AT cyberoptics DOT com
In-Reply-To: <Pine.SUN.3.91.1020212102845.4485C-100000@is> from "Eli Zaretskii" at Feb 12, 2002 10:28:55 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

> > We could add a sbrk(0) call before calling sbrk() with the expected 
> > size - and if it's aligned the sbrk() value should be also.  If
> > sbrk(0) not aligned, we sbrk() the small number of bytes to align - 
> > which will always work (unless there's a equality bug right at the
> > boundary in sbrk...)

Eli replied:

> I like this idea better: it will probably lead to a simpler and more
> localized implementation.

Actually a one line implementation (vs 2.03).  Worked on simple case of
some user sbrk()s tossed in.  And we get to actually use brk() - which
I don't think we've used before :-)

Could also do with sbrk() but would require an if statement.


*** malloc.c_   Wed Dec  5 14:52:52 2001
--- malloc.c    Tue Feb 12 10:52:20 2002
*************** malloc(size_t size)
*** 192,195 ****
--- 192,196 ----
    }

+   brk((void *)( ((int)sbrk(0)+(ALIGN-1)) & ~(ALIGN-1) )); /* Align next sbrk */
    chunk_size = size+16; /* two ends plus two placeholders */
    rv = (BLOCK *)sbrk(chunk_size);

- Raw text -


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