From: Tom Tromey <tromey@redhat.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFA: open-related cleanup handling
Date: Thu, 30 Oct 2008 21:53:00 -0000 [thread overview]
Message-ID: <m363n9kgzd.fsf@fleche.redhat.com> (raw)
In-Reply-To: <200810291740.14621.pedro@codesourcery.com> (Pedro Alves's message of "Wed\, 29 Oct 2008 17\:40\:14 +0000")
>>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:
Pedro> I noticed that discarding a _close cleanup is currently leaking the
Pedro> xmalloc'ed int used to hold the file descriptor. Fixing it should be a
Pedro> matter of doing something similar to make_cleanup_restore_integer
Pedro> (using make_my_cleanup2) from inside make_cleanup_close.
Pedro> Would you like to take care of that while you have your hangs
Pedro> dirty doing these cleaning ups?
No problem.
How about this? I used make_cleanup_dtor -- same difference though.
Built & regtested on x86-64 (compile farm).
What do you think of making make_my_cleanup and make_my_cleanup2 static?
They aren't used outside of utils.c.
Tom
2008-10-30 Tom Tromey <tromey@redhat.com>
* utils.c (make_cleanup_close): Use make_cleanup_dtor.
(do_close_cleanup): Don't free 'fd'.
diff --git a/gdb/utils.c b/gdb/utils.c
index f9a5f19..26d7933 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -244,7 +244,6 @@ do_close_cleanup (void *arg)
{
int *fd = arg;
close (*fd);
- xfree (fd);
}
struct cleanup *
@@ -252,7 +251,7 @@ make_cleanup_close (int fd)
{
int *saved_fd = xmalloc (sizeof (fd));
*saved_fd = fd;
- return make_cleanup (do_close_cleanup, saved_fd);
+ return make_cleanup_dtor (do_close_cleanup, saved_fd, xfree);
}
/* Helper function which does the work for make_cleanup_fclose. */
next prev parent reply other threads:[~2008-10-30 21:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-28 20:21 Tom Tromey
2008-10-29 21:02 ` Pedro Alves
2008-10-30 21:53 ` Tom Tromey [this message]
2008-10-30 21:32 ` Pedro Alves
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=m363n9kgzd.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.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