diff options
author | midipix <writeonce@midipix.org> | 2016-01-03 10:32:23 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-11-10 23:35:35 -0500 |
commit | 17202ae539bb54ae5592652f15a4745afcfb90c2 (patch) | |
tree | b2801753aac045aafa611d41136260268cf39465 /src/internal | |
parent | 6b04c60f081f82190ef83dc417f02e853a01e73d (diff) | |
download | perk-17202ae539bb54ae5592652f15a4745afcfb90c2.tar.bz2 perk-17202ae539bb54ae5592652f15a4745afcfb90c2.tar.xz |
argv.h: fix semantics of calloc() calls.
Diffstat (limited to 'src/internal')
-rw-r--r-- | src/internal/argv/argv.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h index f6ffa48..d76597a 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; i<argc; i++) { @@ -641,7 +641,9 @@ static struct argv_meta * argv_alloc(const char ** argv, struct argv_ctx * ctx) } else imeta->meta.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 |