summaryrefslogtreecommitdiffhomepage
path: root/src/internal/argv
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-06-15 23:06:08 +0000
committermidipix <writeonce@midipix.org>2024-06-22 13:40:12 +0000
commit0ad11985095b9906c877e1f21de928cce8964416 (patch)
tree0cd5d1207f1db94c9f4368ba991ce98e7718213c /src/internal/argv
parentc9de6c7f8dda9e0b8432ac0d524d45538a42d7d5 (diff)
downloadapimagic-0ad11985095b9906c877e1f21de928cce8964416.tar.bz2
apimagic-0ad11985095b9906c877e1f21de928cce8964416.tar.xz
argv.h: argv_alloc(): refactor for better readability.
Diffstat (limited to 'src/internal/argv')
-rw-r--r--src/internal/argv/argv.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h
index c6fe010..1e01086 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(