summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-05-03 13:08:46 +0200
committerVolker Lendecke <vl@samba.org>2009-05-03 13:46:44 +0200
commit2467ae1b6ad3600eeed5223df672111d9ac3f3db (patch)
treeef33af09f4c6c499130804f9149f93db3f4ba248 /lib/util
parenteaf949947c2eb03363c4b6f588f87b70110d6ff7 (diff)
downloadsamba-2467ae1b6ad3600eeed5223df672111d9ac3f3db.tar.gz
samba-2467ae1b6ad3600eeed5223df672111d9ac3f3db.tar.bz2
samba-2467ae1b6ad3600eeed5223df672111d9ac3f3db.zip
Clean up after Tridge's util_strlist changes
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/util.h16
-rw-r--r--lib/util/util_strlist.c39
2 files changed, 30 insertions, 25 deletions
diff --git a/lib/util/util.h b/lib/util/util.h
index 81c7edfbdf..f4c2b833af 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -422,7 +422,7 @@ _PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char
/**
return the number of elements in a string list
*/
-_PUBLIC_ size_t str_list_length(const char **list);
+_PUBLIC_ size_t str_list_length(const char * const *list);
/**
copy a string list
@@ -437,7 +437,7 @@ _PUBLIC_ bool str_list_equal(const char **list1, const char **list2);
/**
add an entry to a string list
*/
-_PUBLIC_ char **str_list_add(char **list, const char *s);
+_PUBLIC_ const char **str_list_add(const char **list, const char *s);
/**
remove an entry from a string list
@@ -456,12 +456,12 @@ _PUBLIC_ bool str_list_check_ci(const char **list, const char *s);
/**
append one list to another - expanding list1
*/
-_PUBLIC_ char **str_list_append(char **list1, const char **list2);
+_PUBLIC_ char **str_list_append(const char **list1, const char * const *list2);
/**
remove duplicate elements from a list
*/
-_PUBLIC_ char **str_list_unique(char **list);
+_PUBLIC_ const char **str_list_unique(const char **list);
/*
very useful when debugging complex list related code
@@ -473,19 +473,21 @@ _PUBLIC_ void str_list_show(const char **list);
append one list to another - expanding list1
this assumes the elements of list2 are const pointers, so we can re-use them
*/
-_PUBLIC_ char **str_list_append_const(char **list1, const char **list2);
+_PUBLIC_ const char **str_list_append_const(const char **list1,
+ const char **list2);
/**
add an entry to a string list
this assumes s will not change
*/
-_PUBLIC_ char **str_list_add_const(char **list, const char *s);
+_PUBLIC_ const char **str_list_add_const(const char **list, const char *s);
/**
copy a string list
this assumes list will not change
*/
-_PUBLIC_ char **str_list_copy_const(TALLOC_CTX *mem_ctx, const char **list);
+_PUBLIC_ const char **str_list_copy_const(TALLOC_CTX *mem_ctx,
+ const char **list);
/* The following definitions come from lib/util/util_file.c */
diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c
index bd7bd00888..6936f189aa 100644
--- a/lib/util/util_strlist.c
+++ b/lib/util/util_strlist.c
@@ -187,7 +187,7 @@ _PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char
/**
return the number of elements in a string list
*/
-_PUBLIC_ size_t str_list_length(const char **list)
+_PUBLIC_ size_t str_list_length(const char * const *list)
{
size_t ret;
for (ret=0;list && list[ret];ret++) /* noop */ ;
@@ -247,12 +247,12 @@ _PUBLIC_ bool str_list_equal(const char **list1, const char **list2)
/**
add an entry to a string list
*/
-_PUBLIC_ char **str_list_add(char **list, const char *s)
+_PUBLIC_ const char **str_list_add(const char **list, const char *s)
{
size_t len = str_list_length(list);
- char **ret;
+ const char **ret;
- ret = talloc_realloc(NULL, list, char *, len+2);
+ ret = talloc_realloc(NULL, list, const char *, len+2);
if (ret == NULL) return NULL;
ret[len] = talloc_strdup(ret, s);
@@ -311,7 +311,7 @@ _PUBLIC_ bool str_list_check_ci(const char **list, const char *s)
/**
append one list to another - expanding list1
*/
-_PUBLIC_ char **str_list_append(char **list1, const char **list2)
+_PUBLIC_ char **str_list_append(const char **list1, const char * const *list2)
{
size_t len1 = str_list_length(list1);
size_t len2 = str_list_length(list2);
@@ -341,15 +341,16 @@ static int list_cmp(const char **el1, const char **el2)
return a list that only contains the unique elements of a list,
removing any duplicates
*/
-_PUBLIC_ char **str_list_unique(char **list)
+_PUBLIC_ const char **str_list_unique(const char **list)
{
size_t len = str_list_length(list);
- char **list2;
+ const char **list2;
int i, j;
if (len < 2) {
return list;
}
- list2 = (char **)talloc_memdup(list, list, sizeof(list[0])*(len+1));
+ list2 = (const char **)talloc_memdup(list, list,
+ sizeof(list[0])*(len+1));
qsort(list2, len, sizeof(list2[0]), QSORT_CAST list_cmp);
list[0] = list2[0];
for (i=j=1;i<len;i++) {
@@ -359,7 +360,7 @@ _PUBLIC_ char **str_list_unique(char **list)
}
}
list[j] = NULL;
- list = talloc_realloc(NULL, list, char *, j);
+ list = talloc_realloc(NULL, list, const char *, j);
talloc_free(list2);
return list;
}
@@ -383,14 +384,15 @@ _PUBLIC_ void str_list_show(const char **list)
append one list to another - expanding list1
this assumes the elements of list2 are const pointers, so we can re-use them
*/
-_PUBLIC_ char **str_list_append_const(char **list1, const char **list2)
+_PUBLIC_ const char **str_list_append_const(const char **list1,
+ const char **list2)
{
size_t len1 = str_list_length(list1);
size_t len2 = str_list_length(list2);
- char **ret;
+ const char **ret;
int i;
- ret = talloc_realloc(NULL, list1, char *, len1+len2+1);
+ ret = talloc_realloc(NULL, list1, const char *, len1+len2+1);
if (ret == NULL) return NULL;
for (i=len1;i<len1+len2;i++) {
@@ -405,12 +407,12 @@ _PUBLIC_ char **str_list_append_const(char **list1, const char **list2)
add an entry to a string list
this assumes s will not change
*/
-_PUBLIC_ char **str_list_add_const(char **list, const char *s)
+_PUBLIC_ const char **str_list_add_const(const char **list, const char *s)
{
size_t len = str_list_length(list);
- char **ret;
+ const char **ret;
- ret = talloc_realloc(NULL, list, char *, len+2);
+ ret = talloc_realloc(NULL, list, const char *, len+2);
if (ret == NULL) return NULL;
ret[len] = s;
@@ -423,15 +425,16 @@ _PUBLIC_ char **str_list_add_const(char **list, const char *s)
copy a string list
this assumes list will not change
*/
-_PUBLIC_ char **str_list_copy_const(TALLOC_CTX *mem_ctx, const char **list)
+_PUBLIC_ const char **str_list_copy_const(TALLOC_CTX *mem_ctx,
+ const char **list)
{
int i;
- char **ret;
+ const char **ret;
if (list == NULL)
return NULL;
- ret = talloc_array(mem_ctx, char *, str_list_length(list)+1);
+ ret = talloc_array(mem_ctx, const char *, str_list_length(list)+1);
if (ret == NULL)
return NULL;