aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-05-03 00:18:20 -0600
committerTom Tromey <tom@tromey.com>2018-05-04 12:20:37 -0600
commitf0b3976bdcd29e308bed185630a24806037a717c (patch)
tree9cb329df8ee78f419c7c0e4dec46db0c9d28f69c /gdb/common
parent862d101ada6b6e8496e545c0bcd801cf8b9a46c1 (diff)
downloadgdb-f0b3976bdcd29e308bed185630a24806037a717c.zip
gdb-f0b3976bdcd29e308bed185630a24806037a717c.tar.gz
gdb-f0b3976bdcd29e308bed185630a24806037a717c.tar.bz2
Remove do_closedir_cleanup
This removes both copies of do_closedir_cleanup in favor of a new unique_ptr specialization. Tested by the buildbot, though I'm not sure that these code paths are exercised there. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * nto-procfs.c (do_closedir_cleanup): Remove. (procfs_pidlist): Use gdb_dir_up. * procfs.c (do_closedir_cleanup): Remove. (proc_update_threads): Use gdb_dir_up. * common/filestuff.h (struct gdb_dir_deleter): New. (gdb_dir_up): New typedef.
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/filestuff.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/common/filestuff.h b/gdb/common/filestuff.h
index 92a2a5f..0e46eb5 100644
--- a/gdb/common/filestuff.h
+++ b/gdb/common/filestuff.h
@@ -19,6 +19,8 @@
#ifndef FILESTUFF_H
#define FILESTUFF_H
+#include <dirent.h>
+
/* Note all the file descriptors which are open when this is called.
These file descriptors will not be closed by close_most_fds. */
@@ -84,4 +86,16 @@ extern int gdb_pipe_cloexec (int filedes[2]);
extern struct cleanup *make_cleanup_close (int fd);
+struct gdb_dir_deleter
+{
+ void operator() (DIR *dir) const
+ {
+ closedir (dir);
+ }
+};
+
+/* A unique pointer to a DIR. */
+
+typedef std::unique_ptr<DIR, gdb_dir_deleter> gdb_dir_up;
+
#endif /* FILESTUFF_H */