[systemd-devel] [RFC 13/25] shared/missing.h: check for missing strndupa
Cristian Rodríguez
crrodriguez at opensuse.org
Thu Sep 18 08:12:18 PDT 2014
El 18/09/14 a las #4, Emil Renner Berthing escribió:
> +#if !HAVE_DECL_STRNDUPA
> +#define strndupa(s, n) \
> + ({ \
> + const char *__old = (s); \
> + size_t __len = strnlen(__old, (n)); \
> + char *__new = (char *)alloca(__len + 1); \
> + __new[__len] = '\0'; \
> + (char *)memcpy(__new, __old, __len); \
> + })
> +#endif
No, get strndupa implemented in the C library instead.
More information about the systemd-devel
mailing list