[asterisk-commits] trunk r34818 - /trunk/build_tools/menuselect.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jun 19 07:24:35 MST 2006


Author: russell
Date: Mon Jun 19 09:24:35 2006
New Revision: 34818

URL: http://svn.digium.com/view/asterisk?rev=34818&view=rev
Log:
copy the definition of ast_strdupa and use it instead of strdupa to fix the
build on systems that don't have it, such as mac

Modified:
    trunk/build_tools/menuselect.c

Modified: trunk/build_tools/menuselect.c
URL: http://svn.digium.com/view/asterisk/trunk/build_tools/menuselect.c?rev=34818&r1=34817&r2=34818&view=diff
==============================================================================
--- trunk/build_tools/menuselect.c (original)
+++ trunk/build_tools/menuselect.c Mon Jun 19 09:24:35 2006
@@ -69,6 +69,18 @@
 
 /*! 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)
@@ -516,7 +528,7 @@
 			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);
@@ -524,7 +536,7 @@
 		}
 
 		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);



More information about the asterisk-commits mailing list