diff options
Diffstat (limited to 'gdb/common')
-rw-r--r-- | gdb/common/filestuff.c | 2 | ||||
-rw-r--r-- | gdb/common/gdb_tilde_expand.c | 2 | ||||
-rw-r--r-- | gdb/common/gdb_unique_ptr.h | 8 | ||||
-rw-r--r-- | gdb/common/pathstuff.c | 8 |
4 files changed, 14 insertions, 6 deletions
diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c index 1ca6248..c7b8c69 100644 --- a/gdb/common/filestuff.c +++ b/gdb/common/filestuff.c @@ -462,7 +462,7 @@ is_regular_file (const char *name, int *errno_ptr) bool mkdir_recursive (const char *dir) { - gdb::unique_xmalloc_ptr<char> holder (xstrdup (dir)); + auto holder = make_unique_xstrdup (dir); char * const start = holder.get (); char *component_start = start; char *component_end = start; diff --git a/gdb/common/gdb_tilde_expand.c b/gdb/common/gdb_tilde_expand.c index fc338ff..326df8f 100644 --- a/gdb/common/gdb_tilde_expand.c +++ b/gdb/common/gdb_tilde_expand.c @@ -91,5 +91,5 @@ gdb_tilde_expand_up (const char *dir) gdb_assert (glob.pathc () > 0); /* "glob" may return more than one match to the path provided by the user, but we are only interested in the first match. */ - return gdb::unique_xmalloc_ptr<char> (xstrdup (glob.pathv ()[0])); + return make_unique_xstrdup (glob.pathv ()[0]); } diff --git a/gdb/common/gdb_unique_ptr.h b/gdb/common/gdb_unique_ptr.h index a4be2bb..67a5f26 100644 --- a/gdb/common/gdb_unique_ptr.h +++ b/gdb/common/gdb_unique_ptr.h @@ -56,4 +56,12 @@ struct noop_deleter } /* namespace gdb */ +/* Dup STR and return a unique_xmalloc_ptr for the result. */ + +static inline gdb::unique_xmalloc_ptr<char> +make_unique_xstrdup (const char *str) +{ + return gdb::unique_xmalloc_ptr<char> (xstrdup (str)); +} + #endif /* COMMON_GDB_UNIQUE_PTR_H */ diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c index 2b1669a..e0e048d 100644 --- a/gdb/common/pathstuff.c +++ b/gdb/common/pathstuff.c @@ -65,7 +65,7 @@ gdb_realpath (const char *filename) we might not be able to display the original casing in a given path. */ if (len > 0 && len < MAX_PATH) - return gdb::unique_xmalloc_ptr<char> (xstrdup (buf)); + return make_unique_xstrdup (buf); } #else { @@ -77,7 +77,7 @@ gdb_realpath (const char *filename) #endif /* This system is a lost cause, just dup the buffer. */ - return gdb::unique_xmalloc_ptr<char> (xstrdup (filename)); + return make_unique_xstrdup (filename); } /* See common/pathstuff.h. */ @@ -92,7 +92,7 @@ gdb_realpath_keepfile (const char *filename) /* Extract the basename of filename, and return immediately a copy of filename if it does not contain any directory prefix. */ if (base_name == filename) - return gdb::unique_xmalloc_ptr<char> (xstrdup (filename)); + return make_unique_xstrdup (filename); dir_name = (char *) alloca ((size_t) (base_name - filename + 2)); /* Allocate enough space to store the dir_name + plus one extra @@ -135,7 +135,7 @@ gdb_abspath (const char *path) return gdb_tilde_expand_up (path); if (IS_ABSOLUTE_PATH (path)) - return gdb::unique_xmalloc_ptr<char> (xstrdup (path)); + return make_unique_xstrdup (path); /* Beware the // my son, the Emacs barfs, the botch that catch... */ return gdb::unique_xmalloc_ptr<char> |