Typecast malloc() return value, of the CPP compiler will hate us.

Signed-off-by: Emil Velikov <[email protected]>
---
 tests/util/piglit-util.c | 27 ---------------------------
 tests/util/piglit-util.h | 36 ++++++++++++++++++++++++++++--------
 2 files changed, 28 insertions(+), 35 deletions(-)

diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index b089944..2652e4b 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -289,33 +289,6 @@ piglit_report_subtest_result(enum piglit_result result, 
const char *format, ...)
        va_end(ap);
 }
 
-#ifndef HAVE_STRCHRNUL
-char *strchrnul(const char *s, int c)
-{
-       char *t = strchr(s, c);
-
-       return (t == NULL) ? ((char *) s + strlen(s)) : t;
-}
-#endif
-
-
-#ifndef HAVE_STRNDUP
-char *strndup(const char *s, size_t n)
-{
-       const size_t len = strlen(s);
-       const size_t size_to_copy = MIN2(n, len);
-
-       char *const copy = malloc(size_to_copy + 1);
-       if (copy != NULL) {
-               memcpy(copy, s, size_to_copy);
-               copy[size_to_copy] = '\0';
-       }
-
-       return copy;
-}
-#endif
-
-
 #ifdef _WIN32
 
 #ifndef DBG_PRINTEXCEPTION_C
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 0e0a8b9..cfec5b5 100755
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -200,6 +200,34 @@ strtod_inf(const char *nptr, char **endptr)
        return strtod(nptr, endptr);
 }
 
+#ifndef HAVE_STRCHRNUL
+static inline char *
+strchrnul(const char *s, int c)
+{
+       char *t = strchr(s, c);
+
+       return (t == NULL) ? ((char *) s + strlen(s)) : t;
+}
+#endif
+
+
+#ifndef HAVE_STRNDUP
+static inline char *
+strndup(const char *s, size_t n)
+{
+       const size_t len = strlen(s);
+       const size_t size_to_copy = MIN2(n, len);
+
+       char *const copy = (char *const) malloc(size_to_copy + 1);
+       if (copy != NULL) {
+               memcpy(copy, s, size_to_copy);
+               copy[size_to_copy] = '\0';
+       }
+
+       return copy;
+}
+#endif
+
 /**
  * Determine if an extension is listed in an extension string
  *
@@ -232,14 +260,6 @@ void piglit_set_timeout(double seconds, enum piglit_result 
timeout_result);
 void piglit_report_subtest_result(enum piglit_result result,
                                  const char *format, ...) PRINTFLIKE(2, 3);
 
-#ifndef HAVE_STRCHRNUL
-char *strchrnul(const char *s, int c);
-#endif
-
-#ifndef HAVE_STRNDUP
-char *strndup(const char *s, size_t n);
-#endif
-
 void piglit_disable_error_message_boxes(void);
 
 extern void piglit_set_rlimit(unsigned long lim);
-- 
2.1.3

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to