From 8802e55c260e3c595c5bf584c8cb823768e51d06 Mon Sep 17 00:00:00 2001 From: "David M. Lee" Date: Wed, 27 Jul 2016 09:56:29 -0500 Subject: 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 --- menuselect/menuselect.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'menuselect/menuselect.h') 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 */ -- cgit v1.2.3