copy the definition of ast_strdupa and use it instead of strdupa to fix the
authorRussell Bryant <russell@russellbryant.com>
Mon, 19 Jun 2006 14:24:35 +0000 (14:24 +0000)
committerRussell Bryant <russell@russellbryant.com>
Mon, 19 Jun 2006 14:24:35 +0000 (14:24 +0000)
build on systems that don't have it, such as mac

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@34818 65c4cc65-6c06-0410-ace0-fbb531ad65f3

build_tools/menuselect.c

index 62be208..3388ccf 100644 (file)
@@ -70,6 +70,18 @@ static int existing_config = 0;
 /*! This is set when the --check-deps argument is provided. */
 static int check_deps = 0;
 
 /*! This is set when the --check-deps argument is provided. */
 static int check_deps = 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
+
 /*! \brief return a pointer to the first non-whitespace character */
 static inline char *skip_blanks(char *str)
 {
 /*! \brief return a pointer to the first non-whitespace character */
 static inline char *skip_blanks(char *str)
 {
@@ -516,7 +528,7 @@ static int generate_makeopts_file(void)
                        had_changes = 1;
 
                        if (mem->remove_on_change) {
                        had_changes = 1;
 
                        if (mem->remove_on_change) {
-                               for (buf = strdupa(mem->remove_on_change), file = strsep(&buf, " ");
+                               for (buf = ast_strdupa(mem->remove_on_change), file = strsep(&buf, " ");
                                     file;
                                     file = strsep(&buf, " "))
                                        unlink(file);
                                     file;
                                     file = strsep(&buf, " "))
                                        unlink(file);
@@ -524,7 +536,7 @@ static int generate_makeopts_file(void)
                }
 
                if (cat->remove_on_change && had_changes) {
                }
 
                if (cat->remove_on_change && had_changes) {
-                       for (buf = strdupa(cat->remove_on_change), file = strsep(&buf, " ");
+                       for (buf = ast_strdupa(cat->remove_on_change), file = strsep(&buf, " ");
                             file;
                             file = strsep(&buf, " "))
                                unlink(file);
                             file;
                             file = strsep(&buf, " "))
                                unlink(file);