[PATCH 35/44] os: xstrtokenize takes and returns const char * now

Keith Packard keithp at keithp.com
Wed Dec 11 12:24:07 PST 2013


Signed-off-by: Keith Packard <keithp at keithp.com>
---
 include/misc.h | 2 +-
 os/utils.c     | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/misc.h b/include/misc.h
index 17de710..165d42e 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -246,7 +246,7 @@ padding_for_int32(const int bytes)
 }
 
 
-extern char **xstrtokenize(const char *str, const char *separators);
+extern const char **xstrtokenize(const char *str, const char *separators);
 extern void FormatInt64(int64_t num, char *string);
 extern void FormatUInt64(uint64_t num, char *string);
 extern void FormatUInt64Hex(uint64_t num, char *string);
diff --git a/os/utils.c b/os/utils.c
index 608ee6a..e81dc5f 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1946,10 +1946,10 @@ CheckUserAuthorization(void)
  * Tokenize a string into a NULL terminated array of strings. Always returns
  * an allocated array unless an error occurs.
  */
-char **
+const char **
 xstrtokenize(const char *str, const char *separators)
 {
-    char **list, **nlist;
+    const char **list, **nlist;
     char *tok, *tmp;
     unsigned num = 0, n;
 
@@ -1977,7 +1977,7 @@ xstrtokenize(const char *str, const char *separators)
  error:
     free(tmp);
     for (n = 0; n < num; n++)
-        free(list[n]);
+        free((void *) list[n]);
     free(list);
     return NULL;
 }
-- 
1.8.4.4



More information about the xorg-devel mailing list