diff options
Diffstat (limited to 'gdb/common/filestuff.h')
-rw-r--r-- | gdb/common/filestuff.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gdb/common/filestuff.h b/gdb/common/filestuff.h index b0a811b..3cf2df6 100644 --- a/gdb/common/filestuff.h +++ b/gdb/common/filestuff.h @@ -46,10 +46,23 @@ extern void close_most_fds (void); extern int gdb_open_cloexec (const char *filename, int flags, /* mode_t */ unsigned long mode); +struct gdb_file_deleter +{ + void operator() (FILE *file) const + { + fclose (file); + } +}; + +/* A unique pointer to a FILE. */ + +typedef std::unique_ptr<FILE, gdb_file_deleter> gdb_file_up; + /* Like 'fopen', but ensures that the returned file descriptor has the close-on-exec flag set. */ -extern FILE *gdb_fopen_cloexec (const char *filename, const char *opentype); +extern gdb_file_up gdb_fopen_cloexec (const char *filename, + const char *opentype); /* Like 'socketpair', but ensures that the returned file descriptors have the close-on-exec flag set. */ |