* utils.c (make_cleanup_close): Use make_cleanup_dtor.

(do_close_cleanup): Don't free 'fd'.
This commit is contained in:
Tom Tromey 2008-10-30 20:33:51 +00:00
parent 9fe4a2165d
commit a05016c09e
2 changed files with 6 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2008-10-30 Tom Tromey <tromey@redhat.com>
* utils.c (make_cleanup_close): Use make_cleanup_dtor.
(do_close_cleanup): Don't free 'fd'.
2008-10-28 Tom Tromey <tromey@redhat.com> 2008-10-28 Tom Tromey <tromey@redhat.com>
* source.c (symtab_to_fullname): Test 'r >= 0'. * source.c (symtab_to_fullname): Test 'r >= 0'.

View File

@ -244,7 +244,6 @@ do_close_cleanup (void *arg)
{ {
int *fd = arg; int *fd = arg;
close (*fd); close (*fd);
xfree (fd);
} }
struct cleanup * struct cleanup *
@ -252,7 +251,7 @@ make_cleanup_close (int fd)
{ {
int *saved_fd = xmalloc (sizeof (fd)); int *saved_fd = xmalloc (sizeof (fd));
*saved_fd = 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. */ /* Helper function which does the work for make_cleanup_fclose. */