From: Jonas Fonseca Date: Wed, 23 Jun 2010 02:23:35 +0000 (-0400) Subject: Refactor argv_size out from argv_append X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e63f5aaf6f56ebcb60bc34615db52d849585740d;p=tig.git Refactor argv_size out from argv_append --- diff --git a/tig.c b/tig.c index a82a468..e2e83ff 100644 --- 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;