From: Phil Muldoon <pmuldoon@redhat.com>
To: tromey@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] valprint.c (read_string): Rework clean-up logic.
Date: Fri, 27 Feb 2009 22:11:00 -0000 [thread overview]
Message-ID: <49A85774.5090200@redhat.com> (raw)
In-Reply-To: <m37i3b676v.fsf@fleche.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 259 bytes --]
Tom Tromey wrote:
>
> Phil> + old_chain = make_cleanup (xfree_gdb_byte, buffer);
>
> ... and you can just s/xfree_gdb_byte/free_current_contents/ here.
>
> It is ok with that change. Thanks.
>
> Tom
>
Done. I attached the modified patch for reference.
[-- Attachment #2: read_string_cleanup-cvs2.patch --]
[-- Type: text/x-patch, Size: 1351 bytes --]
Index: valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/valprint.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- valprint.c 5 Feb 2009 12:16:25 -0000 1.79
+++ valprint.c 27 Feb 2009 19:33:06 -0000 1.80
@@ -1226,13 +1226,14 @@
some error, such as bumping into the end of the address space. */
found_nul = 0;
- old_chain = make_cleanup (null_cleanup, 0);
+ *buffer = NULL;
+
+ old_chain = make_cleanup (free_current_contents, buffer);
if (len > 0)
{
*buffer = (gdb_byte *) xmalloc (len * width);
bufptr = *buffer;
- old_chain = make_cleanup (xfree, *buffer);
nfetch = partial_memory_read (addr, bufptr, len * width, &errcode)
/ width;
@@ -1243,8 +1244,6 @@
{
unsigned long bufsize = 0;
- *buffer = NULL;
-
do
{
QUIT;
@@ -1253,13 +1252,9 @@
if (*buffer == NULL)
*buffer = (gdb_byte *) xmalloc (nfetch * width);
else
- {
- discard_cleanups (old_chain);
- *buffer = (gdb_byte *) xrealloc (*buffer,
- (nfetch + bufsize) * width);
- }
+ *buffer = (gdb_byte *) xrealloc (*buffer,
+ (nfetch + bufsize) * width);
- old_chain = make_cleanup (xfree, *buffer);
bufptr = *buffer + bufsize * width;
bufsize += nfetch;
prev parent reply other threads:[~2009-02-27 21:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-27 19:41 Phil Muldoon
2009-02-27 19:56 ` Tom Tromey
2009-02-27 22:11 ` Phil Muldoon [this message]
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=49A85774.5090200@redhat.com \
--to=pmuldoon@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.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