summaryrefslogtreecommitdiff
path: root/menuselect/menuselect.h
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@respoke.io>2016-07-27 09:56:29 -0500
committerGeorge Joseph <gjoseph@digium.com>2016-08-01 10:53:19 -0600
commitdf42f64d62cf6c158a391db4ff1b4c57b87dbf10 (patch)
treee6046ba90d6fd8d3d6b3ee415c946d16f0721505 /menuselect/menuselect.h
parent56a07fbab9bdabc562d88706067ce53f7025a660 (diff)
Replace strdupa with more portable ast_strdupa
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
Diffstat (limited to 'menuselect/menuselect.h')
-rw-r--r--menuselect/menuselect.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/menuselect/menuselect.h b/menuselect/menuselect.h
index 7b3fe2656..328ac9a0a 100644
--- a/menuselect/menuselect.h
+++ b/menuselect/menuselect.h
@@ -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 */