(ASSIGN_STRDUPA): New macro (moved here from remove.c).
authorJim Meyering <jim@meyering.net>
Sun, 23 Jul 2000 10:49:59 +0000 (10:49 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 23 Jul 2000 10:49:59 +0000 (10:49 +0000)
src/sys2.h

index 8cd759045243852c4e22049cb149f758fde29de2..64402a9b60b87f7565d058bc6fa9ca4802a02899 100644 (file)
@@ -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