diff options
author | David M. Lee <dlee@respoke.io> | 2016-07-27 09:56:29 -0500 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2016-07-27 10:29:44 -0500 |
commit | 8802e55c260e3c595c5bf584c8cb823768e51d06 (patch) | |
tree | 6f450af375ac43e809e87be04c4f7f238b4b2988 /menuselect/menuselect.h | |
parent | 49461f37b75aa27275d1c4811007e2a7f94ac002 (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.h | 12 |
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 */ |