]> git.ozlabs.org Git - ccan/blobdiff - ccan/str_talloc/str_talloc.c
strsplit: remove nump argument
[ccan] / ccan / str_talloc / str_talloc.c
index e2d12df8791942744f3dec63f2e9a18284198a4d..3bcb1f2a9cf3f7836603bfa9cbed7524f98c87ff 100644 (file)
@@ -11,8 +11,7 @@
 #include <ccan/talloc/talloc.h>
 #include <ccan/str/str.h>
 
-char **strsplit(const void *ctx, const char *string, const char *delims,
-                unsigned int *nump)
+char **strsplit(const void *ctx, const char *string, const char *delims)
 {
        char **lines = NULL;
        unsigned int max = 64, num = 0;
@@ -30,9 +29,9 @@ char **strsplit(const void *ctx, const char *string, const char *delims,
                        lines = talloc_realloc(ctx, lines, char *, max*=2 + 1);
        }
        lines[num] = NULL;
-       if (nump)
-               *nump = num;
-       return lines;
+
+       /* Shrink, so talloc_get_size works */
+       return talloc_realloc(ctx, lines, char *, num+1);
 }
 
 char *strjoin(const void *ctx, char *strings[], const char *delim)