summaryrefslogtreecommitdiff
path: root/strdupa.h
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2013-08-30 20:19:26 +0200
committerGravatar waker <wakeroid@gmail.com>2013-08-30 20:19:26 +0200
commitd7f15ac7306a80fee78631d6ff2d736d125f6414 (patch)
treee1c84f28b483f489c9286087eb00763fb1259a54 /strdupa.h
parent3ad91661619b579076f32ce6c1727c3eb176adde (diff)
moved all copies of strdupa macro to strdupa.h
Diffstat (limited to 'strdupa.h')
-rw-r--r--strdupa.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/strdupa.h b/strdupa.h
new file mode 100644
index 00000000..00a94cb6
--- /dev/null
+++ b/strdupa.h
@@ -0,0 +1,18 @@
+#ifndef __DDB_PLATFORM_H
+#define __DDB_PLATFORM_H
+
+#include <string.h>
+
+#ifndef _GNU_SOURCE
+#ifndef 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
+#endif
+
+#endif