]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Replace strdupa with more portable ast_strdupa 83/3383/1
authorDavid M. Lee <dlee@respoke.io>
Wed, 27 Jul 2016 14:56:29 +0000 (09:56 -0500)
committerGeorge Joseph <gjoseph@digium.com>
Mon, 1 Aug 2016 16:53:19 +0000 (10:53 -0600)
The strdupa function is a GNU extension, and not widely portable. We
have an ast_strdupa function used within Asterisk which is preferred.
I pulled the definition up from menuselect.c into the menuselect.h
header file so it can be shared across menuselect.

Change-Id: I9593c97f78386b47dc1e83201e80cb2f62b36c2e

menuselect/menuselect.c
menuselect/menuselect.h
menuselect/menuselect_curses.c

index efae311bb7a18af97b063910b3b635882893f1a0..f6a7fb39b2d428845bb8513528c8a93a347a5ef7 100644 (file)
@@ -103,18 +103,6 @@ struct dep_file {
 };
 AST_LIST_HEAD_NOLOCK_STATIC(deps_file, dep_file);
 
-#if !defined(ast_strdupa) && defined(__GNUC__)
-#define ast_strdupa(s)                                                    \
-       (__extension__                                                    \
-       ({                                                                \
-               const char *__old = (s);                                  \
-               size_t __len = strlen(__old) + 1;                         \
-               char *__new = __builtin_alloca(__len);                    \
-               memcpy (__new, __old, __len);                             \
-               __new;                                                    \
-       }))
-#endif
-
 /*! \brief return a pointer to the first non-whitespace character */
 static inline char *skip_blanks(char *str)
 {
index 7b3fe26567cb417f8a9ec6ac5e83bafeca7c0463..328ac9a0ab8c72b9dc5316d0e1e0731e3423a7cd 100644 (file)
@@ -162,4 +162,16 @@ static inline int strlen_zero(const char *s)
        return (!s || (*s == '\0'));
 }
 
+#if !defined(ast_strdupa) && defined(__GNUC__)
+#define ast_strdupa(s)                                                    \
+       (__extension__                                                    \
+       ({                                                                \
+               const char *__old = (s);                                  \
+               size_t __len = strlen(__old) + 1;                         \
+               char *__new = __builtin_alloca(__len);                    \
+               memcpy (__new, __old, __len);                             \
+               __new;                                                    \
+       }))
+#endif
+
 #endif /* MENUSELECT_H */
index e79957485f1f7d571d6dea7d5c4fa8267fedc2ec..260cf69a73bb08ca4391b2b8063b2f6bf7a2c5b9 100644 (file)
@@ -211,7 +211,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
 
        if (mem->displayname) {
                char buf[maxlen + 1];
-               char *displayname = strdupa(mem->displayname);
+               char *displayname = ast_strdupa(mem->displayname);
                char *word;
                int current_line = 1;
                int new_line = 1;