Code

Refactor argv_size out from argv_append
authorJonas Fonseca <fonseca@diku.dk>
Wed, 23 Jun 2010 02:23:35 +0000 (22:23 -0400)
committerJonas Fonseca <fonseca@diku.dk>
Wed, 23 Jun 2010 02:53:45 +0000 (22:53 -0400)
tig.c

diff --git a/tig.c b/tig.c
index a82a4686e4696316a00eeb9473d8deb934df6e4b..e2e83ff8fb320acb494796479f5288eb7e5d6e71 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -684,15 +684,23 @@ argv_free(const char *argv[])
        argv[0] = NULL;
 }
 
+static size_t
+argv_size(const char **argv)
+{
+       int argc = 0;
+
+       while (argv && argv[argc])
+               argc++;
+
+       return argc;
+}
+
 DEFINE_ALLOCATOR(argv_realloc, const char *, SIZEOF_ARG)
 
 static bool
 argv_append(const char ***argv, const char *arg)
 {
-       int argc = 0;
-
-       while (*argv && (*argv)[argc])
-               argc++;
+       size_t argc = argv_size(*argv);
 
        if (!argv_realloc(argv, argc, 2))
                return FALSE;