From: David Taylor <taylor@cygnus.com>
To: Kevin Buettner <kevinb@cygnus.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH RFA] utils.c: Fix xcalloc (0, 0) behavior
Date: Mon, 05 Mar 2001 07:52:00 -0000 [thread overview]
Message-ID: <200103051552.KAA27848@texas.cygnus.com> (raw)
Date: Sat, 3 Mar 2001 00:58:08 -0700
From: Kevin Buettner <kevinb@cygnus.com>
According to section 16.1 in Harbison & Steele, it is permissible for
calloc(0,0) to return either NULL or an implementation defined unique
pointer. I've come across an implementation of calloc() which chooses
to return NULL.
Unfortunately, our implementation of xcalloc() and xmrealloc() choose
to treat the NULL return value as an error condition and call nomem()
as a result.
The patch below corrects this oversight.
Okay to apply?
* utils.c (xmrealloc): Don't call nomem() when return value
is NULL _and_ request size is 0.
(xcalloc): Likewise.
Yes. Approved.
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.31
diff -u -p -r1.31 utils.c
--- utils.c 2001/02/25 04:45:11 1.31
+++ utils.c 2001/03/03 07:47:54
@@ -1050,7 +1050,7 @@ xmrealloc (PTR md, PTR ptr, long size)
{
val = mmalloc (md, size);
}
- if (val == NULL)
+ if (val == NULL && size != 0)
{
nomem (size);
}
@@ -1072,7 +1072,7 @@ PTR
xcalloc (size_t number, size_t size)
{
void *mem = mcalloc (NULL, number, size);
- if (mem == NULL)
+ if (mem == NULL && number != 0 && size != 0)
nomem (number * size);
return mem;
}
next reply other threads:[~2001-03-05 7:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-05 7:52 David Taylor [this message]
[not found] <1010303075808.ZM24102@ocotillo.lan>
2001-03-03 0:02 ` Kevin Buettner
2001-03-05 12:28 ` Andrew Cagney
2001-03-05 12:39 ` J.T. Conklin
2001-03-05 12:51 ` Kevin Buettner
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=200103051552.KAA27848@texas.cygnus.com \
--to=taylor@cygnus.com \
--cc=gdb-patches@sources.redhat.com \
--cc=kevinb@cygnus.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