From db73e42c46e02065e3ad64b93c5d0ecc3fb0e6b1 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 15 Jun 2024 23:06:08 +0000 Subject: argv.h: argv_alloc(): refactor for better readability. --- src/internal/argv/argv.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/internal/argv/argv.h') diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h index 1f9d6f3..b634696 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; imeta.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( -- cgit v1.2.3