From 654e6495f3839b772aa0ac83a5072df4092ff522 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 3 Jan 2016 10:29:54 -0500 Subject: argv.h: fix semantics of calloc() calls. --- src/internal/argv/argv.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/internal/argv') diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h index 299411a..45ea8b5 100644 --- a/src/internal/argv/argv.h +++ b/src/internal/argv/argv.h @@ -617,7 +617,7 @@ static struct argv_meta * argv_alloc(const char ** argv, struct argv_ctx * ctx) int argc; int i; - if (!(imeta = calloc(sizeof(*imeta),1))) + if (!(imeta = calloc(1,sizeof(*imeta)))) return 0; if (ctx->flags & ARGV_CLONE_VECTOR) { @@ -626,9 +626,9 @@ static struct argv_meta * argv_alloc(const char ** argv, struct argv_ctx * ctx) argc++; } - if (!(imeta->argv = calloc(sizeof(char *),argc+1))) + if (!(imeta->argv = calloc(argc+1,sizeof(char *)))) return argv_free_impl(imeta); - else if (!(imeta->strbuf = calloc(size+1,1))) + else if (!(imeta->strbuf = calloc(1,size+1))) return argv_free_impl(imeta); for (i=0,dst=imeta->strbuf; imeta.argv = argv; - if (!(imeta->meta.entries = calloc(sizeof(struct argv_entry),ctx->nentries+1))) + if (!(imeta->meta.entries = calloc( + ctx->nentries+1, + sizeof(struct argv_entry)))) return argv_free_impl(imeta); else return &imeta->meta; @@ -856,7 +858,7 @@ static void argv_usage( len = rdesclen + 512; len &= (~511); - if ((buf = calloc(len,1))) { + if ((buf = calloc(1,len))) { buflen = len; if (option->paradigm) @@ -884,7 +886,7 @@ static void argv_usage( (int)(paralen-strlen(option->paradigm)-rbblen),' '); para = (char *)0; } else if (option->paradigm) { - if (!paradigm && !(paradigm = calloc(mparalen,1))) { + if (!paradigm && !(paradigm = calloc(1,mparalen))) { fputc('\n',file); continue; } else -- cgit v1.2.3