Move make_cleanup_close to common code
This commit moves the function make_cleanup_close from gdb/utils.[ch] to gdb/common/filestuff.[ch] to make it usable from common code. gdb/ChangeLog: * utils.h (make_cleanup_close): Moved to common/filestuff.h. * utils.c (do_close_cleanup): Moved to common/filestuff.c. (make_cleanup_close): Likewise. * common/filestuff.h (make_cleanup_close): Moved from utils.h. * common/filestuff.c (do_close_cleanup): Moved from utils.c. (make_cleanup_close): Likewise.
This commit is contained in:
parent
5d9c55d355
commit
ca09583623
|
@ -1,3 +1,12 @@
|
||||||
|
2015-06-10 Gary Benson <gbenson@redhat.com>
|
||||||
|
|
||||||
|
* utils.h (make_cleanup_close): Moved to common/filestuff.h.
|
||||||
|
* utils.c (do_close_cleanup): Moved to common/filestuff.c.
|
||||||
|
(make_cleanup_close): Likewise.
|
||||||
|
* common/filestuff.h (make_cleanup_close): Moved from utils.h.
|
||||||
|
* common/filestuff.c (do_close_cleanup): Moved from utils.c.
|
||||||
|
(make_cleanup_close): Likewise.
|
||||||
|
|
||||||
2015-06-03 Jon Turney <jon.turney@dronecode.org.uk>
|
2015-06-03 Jon Turney <jon.turney@dronecode.org.uk>
|
||||||
|
|
||||||
* windows-nat.c (thread_rec): Also ignore ERROR_INVALID_HANDLE
|
* windows-nat.c (thread_rec): Also ignore ERROR_INVALID_HANDLE
|
||||||
|
|
|
@ -404,3 +404,24 @@ gdb_pipe_cloexec (int filedes[2])
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Helper function which does the work for make_cleanup_close. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_close_cleanup (void *arg)
|
||||||
|
{
|
||||||
|
int *fd = arg;
|
||||||
|
|
||||||
|
close (*fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See cleanup-utils.h. */
|
||||||
|
|
||||||
|
struct cleanup *
|
||||||
|
make_cleanup_close (int fd)
|
||||||
|
{
|
||||||
|
int *saved_fd = xmalloc (sizeof (fd));
|
||||||
|
|
||||||
|
*saved_fd = fd;
|
||||||
|
return make_cleanup_dtor (do_close_cleanup, saved_fd, xfree);
|
||||||
|
}
|
||||||
|
|
|
@ -67,4 +67,8 @@ extern int gdb_socket_cloexec (int domain, int style, int protocol);
|
||||||
|
|
||||||
extern int gdb_pipe_cloexec (int filedes[2]);
|
extern int gdb_pipe_cloexec (int filedes[2]);
|
||||||
|
|
||||||
|
/* Return a new cleanup that closes FD. */
|
||||||
|
|
||||||
|
extern struct cleanup *make_cleanup_close (int fd);
|
||||||
|
|
||||||
#endif /* FILESTUFF_H */
|
#endif /* FILESTUFF_H */
|
||||||
|
|
17
gdb/utils.c
17
gdb/utils.c
|
@ -191,23 +191,6 @@ make_cleanup_bfd_unref (bfd *abfd)
|
||||||
return make_cleanup (do_bfd_close_cleanup, abfd);
|
return make_cleanup (do_bfd_close_cleanup, abfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
do_close_cleanup (void *arg)
|
|
||||||
{
|
|
||||||
int *fd = arg;
|
|
||||||
|
|
||||||
close (*fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct cleanup *
|
|
||||||
make_cleanup_close (int fd)
|
|
||||||
{
|
|
||||||
int *saved_fd = xmalloc (sizeof (fd));
|
|
||||||
|
|
||||||
*saved_fd = 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. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -80,7 +80,7 @@ struct section_addr_info;
|
||||||
extern struct cleanup *(make_cleanup_free_section_addr_info
|
extern struct cleanup *(make_cleanup_free_section_addr_info
|
||||||
(struct section_addr_info *));
|
(struct section_addr_info *));
|
||||||
|
|
||||||
extern struct cleanup *make_cleanup_close (int fd);
|
/* For make_cleanup_close see common/filestuff.h. */
|
||||||
|
|
||||||
extern struct cleanup *make_cleanup_fclose (FILE *file);
|
extern struct cleanup *make_cleanup_fclose (FILE *file);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue