From: Jeremy Allison Date: Thu, 24 Sep 2009 22:52:58 +0000 (-0700) Subject: Remove the const from the str_list_XXX functions that X-Git-Tag: talloc-2.0.1~379^2~4 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=d1aa7d479697a8fcc5d8237271c473a1b831949b;p=samba.git Remove the const from the str_list_XXX functions that allocate both list and containing strings. This fixes problems that people have tried to cast away and are not needed. Jeremy. --- diff --git a/lib/util/util.h b/lib/util/util.h index 385a3ae07a1..c766e3dce73 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -407,12 +407,12 @@ _PUBLIC_ bool strequal(const char *s1, const char *s2); /** build an empty (only NULL terminated) list of strings (for expansion with str_list_add() etc) */ -_PUBLIC_ const char **str_list_make_empty(TALLOC_CTX *mem_ctx); +_PUBLIC_ char **str_list_make_empty(TALLOC_CTX *mem_ctx); /** place the only element 'entry' into a new, NULL terminated string list */ -_PUBLIC_ const char **str_list_make_single(TALLOC_CTX *mem_ctx, +_PUBLIC_ char **str_list_make_single(TALLOC_CTX *mem_ctx, const char *entry); /** @@ -420,7 +420,7 @@ _PUBLIC_ const char **str_list_make_single(TALLOC_CTX *mem_ctx, separator list. The separator list must contain characters less than or equal to 0x2f for this to work correctly on multi-byte strings */ -_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, +_PUBLIC_ char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep); /** @@ -428,7 +428,7 @@ _PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, * Entries are seperated by spaces and can be enclosed by quotes. * Does NOT support escaping */ -_PUBLIC_ const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep); +_PUBLIC_ char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep); /** * join a list back to one string @@ -447,7 +447,7 @@ _PUBLIC_ size_t str_list_length(const char * const *list); /** copy a string list */ -_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list); +_PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list); /** Return true if all the elements of the list match exactly. diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c index b4b991f3db1..1331fee6a70 100644 --- a/lib/util/util_strlist.c +++ b/lib/util/util_strlist.c @@ -31,11 +31,11 @@ /** build an empty (only NULL terminated) list of strings (for expansion with str_list_add() etc) */ -_PUBLIC_ const char **str_list_make_empty(TALLOC_CTX *mem_ctx) +_PUBLIC_ char **str_list_make_empty(TALLOC_CTX *mem_ctx) { - const char **ret = NULL; + char **ret = NULL; - ret = talloc_array(mem_ctx, const char *, 1); + ret = talloc_array(mem_ctx, char *, 1); if (ret == NULL) { return NULL; } @@ -48,11 +48,11 @@ _PUBLIC_ const char **str_list_make_empty(TALLOC_CTX *mem_ctx) /** place the only element 'entry' into a new, NULL terminated string list */ -_PUBLIC_ const char **str_list_make_single(TALLOC_CTX *mem_ctx, const char *entry) +_PUBLIC_ char **str_list_make_single(TALLOC_CTX *mem_ctx, const char *entry) { - const char **ret = NULL; + char **ret = NULL; - ret = talloc_array(mem_ctx, const char *, 2); + ret = talloc_array(mem_ctx, char *, 2); if (ret == NULL) { return NULL; } @@ -72,30 +72,30 @@ _PUBLIC_ const char **str_list_make_single(TALLOC_CTX *mem_ctx, const char *entr separator list. The separator list must contain characters less than or equal to 0x2f for this to work correctly on multi-byte strings */ -_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) +_PUBLIC_ char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) { int num_elements = 0; - const char **ret = NULL; + char **ret = NULL; if (sep == NULL) { sep = LIST_SEP; } - ret = talloc_array(mem_ctx, const char *, 1); + ret = talloc_array(mem_ctx, char *, 1); if (ret == NULL) { return NULL; } while (string && *string) { size_t len = strcspn(string, sep); - const char **ret2; + char **ret2; if (len == 0) { string += strspn(string, sep); continue; } - ret2 = talloc_realloc(mem_ctx, ret, const char *, + ret2 = talloc_realloc(mem_ctx, ret, char *, num_elements+2); if (ret2 == NULL) { talloc_free(ret); @@ -123,12 +123,12 @@ _PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, con * Entries are seperated by spaces and can be enclosed by quotes. * Does NOT support escaping */ -_PUBLIC_ const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep) +_PUBLIC_ char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep) { int num_elements = 0; - const char **ret = NULL; + char **ret = NULL; - ret = talloc_array(mem_ctx, const char *, 1); + ret = talloc_array(mem_ctx, char *, 1); if (ret == NULL) { return NULL; } @@ -139,7 +139,7 @@ _PUBLIC_ const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *strin while (string && *string) { size_t len = strcspn(string, sep); char *element; - const char **ret2; + char **ret2; if (len == 0) { string += strspn(string, sep); @@ -161,7 +161,7 @@ _PUBLIC_ const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *strin return NULL; } - ret2 = talloc_realloc(mem_ctx, ret, const char *, num_elements+2); + ret2 = talloc_realloc(mem_ctx, ret, char *, num_elements+2); if (ret2 == NULL) { talloc_free(ret); return NULL; @@ -238,15 +238,15 @@ _PUBLIC_ size_t str_list_length(const char * const *list) /** copy a string list */ -_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list) +_PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list) { int i; - const char **ret; + char **ret; if (list == NULL) return NULL; - ret = talloc_array(mem_ctx, const char *, str_list_length(list)+1); + ret = talloc_array(mem_ctx, char *, str_list_length(list)+1); if (ret == NULL) return NULL;