Blob Blame History Raw
From be60850c79dcb62cf682ea496ec22d8ea45f9da2 Mon Sep 17 00:00:00 2001
From: Chih-Wei Huang <cwhuang@linux.org.tw>
Date: Thu, 10 Jan 2019 16:44:38 +0800
Subject: [PATCH 06/63] Define strdupa if it is not defined

Android does not include strdupa in <string.h>. Define strdupa if it has
not already been defined.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
---
 src/util.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/util.h b/src/util.h
index 6d3c10e946e..d98bfa1beed 100644
--- a/src/util.h
+++ b/src/util.h
@@ -252,6 +252,17 @@ lcm(uint64_t x, uint64_t y)
         return (x / n) * y;
 }
 
+#ifndef strdupa
+#define strdupa(s)                                                      \
+       (__extension__ ({                                                \
+                const char *__in = (s);                                 \
+                size_t __len = strlen (__in);                           \
+                char *__out = (char *) alloca (__len + 1);              \
+                strcpy(__out, __in);                                    \
+                __out;                                                  \
+        }))
+#endif
+
 #ifndef strndupa
 #define strndupa(s, l)                                                  \
        (__extension__ ({                                                \
-- 
2.26.2