Blame SOURCES/0006-Define-strdupa-if-it-is-not-defined.patch

4e0e09
From be60850c79dcb62cf682ea496ec22d8ea45f9da2 Mon Sep 17 00:00:00 2001
4e0e09
From: Chih-Wei Huang <cwhuang@linux.org.tw>
4e0e09
Date: Thu, 10 Jan 2019 16:44:38 +0800
4e0e09
Subject: [PATCH 06/63] Define strdupa if it is not defined
4e0e09
4e0e09
Android does not include strdupa in <string.h>. Define strdupa if it has
4e0e09
not already been defined.
4e0e09
4e0e09
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
4e0e09
---
4e0e09
 src/util.h | 11 +++++++++++
4e0e09
 1 file changed, 11 insertions(+)
4e0e09
4e0e09
diff --git a/src/util.h b/src/util.h
4e0e09
index 6d3c10e946e..d98bfa1beed 100644
4e0e09
--- a/src/util.h
4e0e09
+++ b/src/util.h
4e0e09
@@ -252,6 +252,17 @@ lcm(uint64_t x, uint64_t y)
4e0e09
         return (x / n) * y;
4e0e09
 }
4e0e09
 
4e0e09
+#ifndef strdupa
4e0e09
+#define strdupa(s)                                                      \
4e0e09
+       (__extension__ ({                                                \
4e0e09
+                const char *__in = (s);                                 \
4e0e09
+                size_t __len = strlen (__in);                           \
4e0e09
+                char *__out = (char *) alloca (__len + 1);              \
4e0e09
+                strcpy(__out, __in);                                    \
4e0e09
+                __out;                                                  \
4e0e09
+        }))
4e0e09
+#endif
4e0e09
+
4e0e09
 #ifndef strndupa
4e0e09
 #define strndupa(s, l)                                                  \
4e0e09
        (__extension__ ({                                                \
4e0e09
-- 
4e0e09
2.26.2
4e0e09