www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/07/06/05:59:58

Date: Fri, 06 Jul 2001 12:56:55 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: djgpp-workers AT delorie DOT com
Message-Id: <3791-Fri06Jul2001125654+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
In-reply-to: <Pine.SUN.3.91.1010704120459.4589A-100000@is> (message from Eli
Zaretskii on Wed, 4 Jul 2001 12:05:57 +0300 (IDT))
Subject: Re: malloc() problem, DJDEV 203
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1010704120459 DOT 4589A-100000 AT is>
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

> Date: Wed, 4 Jul 2001 12:05:57 +0300 (IDT)
> From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
> 
> On Tue, 3 Jul 2001, I wrote:
> 
> > If that doesn't work, I think we can safely decline anything above 2GB, 
> > which will avoid the signed/unsigned nuisance (inside malloc as well).
> 
> Does the following look right?

I committed this, after moving the test before the alignment, as per
DJ's suggestion, and after adding a note in wc204.txi.

> --- malloc.c~0	Wed Jul  4 09:55:04 2001
> +++ malloc.c	Wed Jul  4 11:10:02 2001
> @@ -132,6 +132,16 @@ malloc(size_t size)
>  
>    if (size<ALIGN) size = ALIGN;
>    size = (size+(ALIGN-1))&~(ALIGN-1);
> +
> +  /* Refuse ridiculously large requests right away.  Anything beyond
> +     2GB will be treated by sbrk as a negative request, i.e. as a
> +     request to _decrease_ the heap size.  */
> +  if (size > 0x7fffffff - 0x10000) /* sbrk rounds up to 64KB */
> +  {
> +    if (__libc_malloc_fail_hook)
> +      __libc_malloc_fail_hook(size);
> +    return 0;
> +  }
>  #if DEBUG
>    printf("malloc(%u)\n", size);
>  #endif
> 
> 

- Raw text -


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