diff options
Diffstat (limited to 'strdupa.h')
-rw-r--r-- | strdupa.h | 18 |
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 |