diff options
author | Volker Lendecke <vl@samba.org> | 2017-08-02 17:22:34 +0200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2018-05-24 12:50:12 +0200 |
commit | 9d402a960966a51ba96458f401542ffa3801497f (patch) | |
tree | 79ee47ba5535190dda253a80f6cb911f2d6b39b2 /lib/util | |
parent | 4dc19aced2c2d5b44a4c89e64c0445953911e917 (diff) | |
download | samba-9d402a960966a51ba96458f401542ffa3801497f.tar.gz |
lib: Pass in "strv_len" to strv_valid_entry
Preparation for a later commit
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13369
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/strv.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/util/strv.c b/lib/util/strv.c index 99ce76f54fd..864a3e5cf8b 100644 --- a/lib/util/strv.c +++ b/lib/util/strv.c @@ -62,27 +62,23 @@ int strv_append(TALLOC_CTX *mem_ctx, char **strv, const char *src) return _strv_append(mem_ctx, strv, src, talloc_array_length(src)); } -static bool strv_valid_entry(const char *strv, const char *entry, - size_t *strv_len, size_t *entry_len) +static bool strv_valid_entry(const char *strv, size_t strv_len, + const char *entry, size_t *entry_len) { - size_t len; - - len = talloc_array_length(strv); - if (len == 0) { + if (strv_len == 0) { return false; } - if (strv[len-1] != '\0') { + if (strv[strv_len-1] != '\0') { return false; } if (entry < strv) { return false; } - if (entry >= (strv+len)) { + if (entry >= (strv+strv_len)) { return false; } - *strv_len = len; *entry_len = strlen(entry); return true; @@ -90,17 +86,18 @@ static bool strv_valid_entry(const char *strv, const char *entry, char *strv_next(char *strv, const char *entry) { - size_t len, entry_len; + size_t len = talloc_array_length(strv); + size_t entry_len; char *result; if (entry == NULL) { - if (strv_valid_entry(strv, strv, &len, &entry_len)) { + if (strv_valid_entry(strv, len, strv, &entry_len)) { return strv; } return NULL; } - if (!strv_valid_entry(strv, entry, &len, &entry_len)) { + if (!strv_valid_entry(strv, len, entry, &entry_len)) { return NULL; } result = &strv[entry - strv]; /* avoid const problems with this stmt */ @@ -139,13 +136,14 @@ char *strv_find(char *strv, const char *entry) void strv_delete(char **strv, char *entry) { - size_t len, entry_len; + size_t len = talloc_array_length(*strv); + size_t entry_len; if (entry == NULL) { return; } - if (!strv_valid_entry(*strv, entry, &len, &entry_len)) { + if (!strv_valid_entry(*strv, len, entry, &entry_len)) { return; } entry_len += 1; |