diff options
author | midipix <writeonce@midipix.org> | 2016-01-03 10:29:54 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-01-03 10:29:54 -0500 |
commit | 654e6495f3839b772aa0ac83a5072df4092ff522 (patch) | |
tree | cb4de88566a06f5e3d8fc42975eb2af1849a740e /src | |
parent | d83bc0ff7a851e3f3f8409b9f32d5287270721fc (diff) | |
download | apimagic-654e6495f3839b772aa0ac83a5072df4092ff522.tar.bz2 apimagic-654e6495f3839b772aa0ac83a5072df4092ff522.tar.xz |
argv.h: fix semantics of calloc() calls.
Diffstat (limited to 'src')
-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 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; 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 |