mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-06 16:09:43 +00:00
utils: provide strdupa() if not in libc
FreeBSD does not have strdupa(), provide it locally then. Macro by: Gleb Popov <arrowd@FreeBSD.org>
This commit is contained in:
parent
c89af625db
commit
685ff1dc25
|
@ -40,6 +40,7 @@
|
|||
#include <spa/param/profiler.h>
|
||||
#include <spa/debug/pod.h>
|
||||
|
||||
#include <pipewire/utils.h>
|
||||
#include <pipewire/private.h>
|
||||
#include <pipewire/impl.h>
|
||||
#include <extensions/profiler.h>
|
||||
|
|
|
@ -66,6 +66,16 @@ pw_strip(char *str, const char *whitespace);
|
|||
})
|
||||
#endif
|
||||
|
||||
#if !defined(strdupa)
|
||||
# define strdupa(s) \
|
||||
({ \
|
||||
const char *__old = (s); \
|
||||
size_t __len = strlen(__old) + 1; \
|
||||
char *__new = (char *) alloca(__len); \
|
||||
(char *) memcpy(__new, __old, __len); \
|
||||
})
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue