From: Andre Noll Date: Mon, 19 Jun 2023 17:56:26 +0000 (+0200) Subject: create_argv_offset(): Use arr_zalloc(). X-Git-Tag: v0.7.3~5 X-Git-Url: http://git.tuebingen.mpg.de/versions/paraslash-0.3.1.tar.bz2.asc?a=commitdiff_plain;h=685698f0adeb1906f14a1b05d976943cba4ca7e3;p=paraslash.git create_argv_offset(): Use arr_zalloc(). There is no point in initializing the allocated array manually, and it does not hurt to initialize also the last element. --- diff --git a/string.c b/string.c index 46b34623..423fd296 100644 --- a/string.c +++ b/string.c @@ -739,13 +739,11 @@ void free_argv(char **argv) static int create_argv_offset(int offset, const char *buf, const char *delim, char ***result) { - char *word, **argv = arr_alloc(offset + 1, sizeof(char *)); + char *word, **argv = arr_zalloc(offset + 1, sizeof(char *)); const char *p; int i, ret; - for (i = 0; i < offset; i++) - argv[i] = NULL; - for (p = buf; p && *p; p += ret, i++) { + for (p = buf, i = offset; p && *p; p += ret, i++) { ret = get_next_word(p, delim, &word); if (ret < 0) goto err;