Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@mvista.com>
To: Richard.Earnshaw@arm.com
Cc: "Thomas,Stephen" <stephen.thomas@superh.com>,
	Geoff Keating <geoffk@geoffk.org>,
	gdb@sources.redhat.com, newlib@sources.redhat.com,
	bug-glibc@gnu.org, "McGoogan, Sean" <sean.mcgoogan@superh.com>,
	Andrew Cagney <ac131313@redhat.com>
Subject: Re: memset (0, 0, 0);
Date: Tue, 08 Apr 2003 13:26:00 -0000	[thread overview]
Message-ID: <20030408132559.GA24135@nevyn.them.org> (raw)
In-Reply-To: <200304080929.h389TuE03840@pc960.cambridge.arm.com>

On Tue, Apr 08, 2003 at 10:29:55AM +0100, Richard Earnshaw wrote:
> > 
> > Hi Geoff,
> > 
> > Which xmalloc are you referring to? The xmalloc in this case is a gdb internal function, defined in gdb/utils.c:
> > 
> > PTR xmalloc (size_t size)
> > {
> >   return xmmalloc (NULL, size);
> > }
> > 
> > And xmmalloc is:
> > 
> > void * xmmalloc (void *md, size_t size)
> > {
> >   void *val;
> > 
> >   if (size == 0)
> >     {
> >       val = NULL;
> >     }
> >   else
> >     {
> >       val = mmalloc (md, size);
> >       if (val == NULL)
> > 	nomem (size);
> >     }
> >   return (val);
> > }
> > 
> > So size=0 does indeed return NULL. Also, I have single stepped this code to verify that this is actually what happens.
> 
> It looks as though that implementation of xmalloc doesn't match the 
> general specification of xmalloc, which is that xmalloc must *never* 
> return NULL (see libiberty/xmalloc.c for the specification).
> 
> I'm not sure why gdb is trying to provide its own implementation of these 
> functions and not use those in libiberty.  Andrew?

The ones in libiberty call exit; the ones in gdb call error() and
unwind cleanups.  GDB prefers not to abort when it runs out of memory,
esp. if it can just abort the current operation and reclaim memory.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


  reply	other threads:[~2003-04-08 13:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-08  7:52 Thomas,Stephen
2003-04-08 13:10 ` Richard Earnshaw
2003-04-08 13:26   ` Daniel Jacobowitz [this message]
2003-04-08 16:40     ` Richard Earnshaw
2003-04-08 20:51     ` Andrew Cagney
2003-04-08 17:57 ` Richard Earnshaw
  -- strict thread matches above, loose matches on Subject: below --
2003-04-07  9:22 Thomas,Stephen
2003-04-07 13:07 ` Daniel Jacobowitz
2003-04-07 17:18 ` Geoff Keating
2003-04-04 16:12 Petr Vandrovec
2003-04-04 21:36 ` Andreas Schwab
2003-04-04 14:54 Joern Rennecke
2003-04-04 15:04 ` Daniel Jacobowitz
2003-04-04 15:16 ` Andrew Cagney
2003-04-04 15:21 ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030408132559.GA24135@nevyn.them.org \
    --to=drow@mvista.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=ac131313@redhat.com \
    --cc=bug-glibc@gnu.org \
    --cc=gdb@sources.redhat.com \
    --cc=geoffk@geoffk.org \
    --cc=newlib@sources.redhat.com \
    --cc=sean.mcgoogan@superh.com \
    --cc=stephen.thomas@superh.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox