mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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
This commit is contained in:
committed by
David M. Lee
parent
49461f37b7
commit
8802e55c26
@@ -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 */
|
||||
|
Reference in New Issue
Block a user