From: Jim Meyering Date: Sun, 23 Jul 2000 10:49:59 +0000 (+0000) Subject: (ASSIGN_STRDUPA): New macro (moved here from remove.c). X-Git-Tag: FILEUTILS-4_0x~18 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=418ae892b1d6f91062b3bf3df94e92276593da13;p=thirdparty%2Fcoreutils.git (ASSIGN_STRDUPA): New macro (moved here from remove.c). --- diff --git a/src/sys2.h b/src/sys2.h index 8cd7590452..64402a9b60 100644 --- a/src/sys2.h +++ b/src/sys2.h @@ -526,3 +526,18 @@ char *base_name PARAMS ((char const *)); #ifndef ATTRIBUTE_UNUSED # define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) #endif + +#if defined strdupa +# define ASSIGN_STRDUPA(DEST, S) \ + do { DEST = strdupa(S); } while (0) +#else +# define ASSIGN_STRDUPA(DEST, S) \ + do \ + { \ + const char *s_ = (S); \ + size_t len_ = strlen (s_) + 1; \ + char *tmp_dest_ = (char *) alloca (len_); \ + DEST = memcpy (tmp_dest_, (s_), len_); \ + } \ + while (0) +#endif