diff options
author | midipix <writeonce@midipix.org> | 2024-06-15 23:06:08 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-06-22 13:40:13 +0000 |
commit | 51db5495299d2a78b6a176a427c61b43d2abea54 (patch) | |
tree | 1329c6e3e99449ce0c37bf9bb615dfefcac14150 /src | |
parent | 24dc3a731d8594454f204abfd45f0887c31c5610 (diff) | |
download | ptycon-51db5495299d2a78b6a176a427c61b43d2abea54.tar.bz2 ptycon-51db5495299d2a78b6a176a427c61b43d2abea54.tar.xz |
argv.h: argv_alloc(): refactor for better readability.
Diffstat (limited to 'src')
-rw-r--r-- | src/internal/argv/argv.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h index dbb2c73..15c8042 100644 --- a/src/internal/argv/argv.h +++ b/src/internal/argv/argv.h @@ -750,7 +750,8 @@ static struct argv_meta * argv_alloc(char ** argv, struct argv_ctx * ctx) if (!(imeta->argv = calloc(argc+1,sizeof(char *)))) return argv_free_impl(imeta); - else if (!(imeta->strbuf = calloc(1,size+1))) + + if (!(imeta->strbuf = calloc(1,size+1))) return argv_free_impl(imeta); for (i=0,dst=imeta->strbuf; i<argc; i++) { @@ -760,15 +761,18 @@ static struct argv_meta * argv_alloc(char ** argv, struct argv_ctx * ctx) } imeta->meta.argv = imeta->argv; - } else + } else { imeta->meta.argv = argv; + } - if (!(imeta->meta.entries = calloc( - ctx->nentries+1, - sizeof(struct argv_entry)))) + imeta->meta.entries = calloc( + ctx->nentries+1, + sizeof(struct argv_entry)); + + if (!imeta->meta.entries) return argv_free_impl(imeta); - else - return &imeta->meta; + + return &imeta->meta; } static struct argv_meta * argv_get( |