From 59939313f8452a9d817c178425c2ba3b91798ea9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 18 Nov 2009 10:33:54 +0000 Subject: [PATCH] Make usage of calloc()'s arguments consistent with rest of code base --- ares/ares_init.c | 2 +- ares/ares_process.c | 2 +- lib/cookie.c | 2 +- lib/easy.c | 2 +- lib/file.c | 2 +- lib/formdata.c | 6 +++--- lib/ftp.c | 2 +- lib/hostip.c | 2 +- lib/hostip4.c | 2 +- lib/hostthre.c | 2 +- lib/http.c | 4 ++-- lib/ldap.c | 2 +- lib/multi.c | 8 ++++---- lib/share.c | 2 +- lib/ssh.c | 2 +- lib/sslgen.c | 2 +- lib/ssluse.c | 2 +- lib/tftp.c | 2 +- src/urlglob.c | 2 +- 19 files changed, 25 insertions(+), 25 deletions(-) diff --git a/ares/ares_init.c b/ares/ares_init.c index 92537ab14..028b1453e 100644 --- a/ares/ares_init.c +++ b/ares/ares_init.c @@ -797,7 +797,7 @@ DhcpNameServer return ARES_SUCCESS; /* use localhost DNS server */ nservers = i; - servers = calloc(sizeof(*servers), i); + servers = calloc(i, sizeof(struct server_state)); if (!servers) return ARES_ENOMEM; diff --git a/ares/ares_process.c b/ares/ares_process.c index 0bc3985d8..5df0f60bd 100644 --- a/ares/ares_process.c +++ b/ares/ares_process.c @@ -732,7 +732,7 @@ void ares__send_query(ares_channel channel, struct query *query, return; } } - sendreq = calloc(sizeof(struct send_request), 1); + sendreq = calloc(1, sizeof(struct send_request)); if (!sendreq) { end_query(channel, query, ARES_ENOMEM, NULL, 0); diff --git a/lib/cookie.c b/lib/cookie.c index 89f90f1d3..b76394cfa 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -204,7 +204,7 @@ Curl_cookie_add(struct SessionHandle *data, #endif /* First, alloc and init a new struct for it */ - co = calloc(sizeof(struct Cookie), 1); + co = calloc(1, sizeof(struct Cookie)); if(!co) return NULL; /* bail out if we're this low on memory */ diff --git a/lib/easy.c b/lib/easy.c index 0fee13f3e..ee74fa62e 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -619,7 +619,7 @@ CURL *curl_easy_duphandle(CURL *incurl) bool fail = TRUE; struct SessionHandle *data=(struct SessionHandle *)incurl; - struct SessionHandle *outcurl = calloc(sizeof(struct SessionHandle), 1); + struct SessionHandle *outcurl = calloc(1, sizeof(struct SessionHandle)); if(NULL == outcurl) return NULL; /* failure */ diff --git a/lib/file.c b/lib/file.c index 3d1d2bbcb..b4dc17d93 100644 --- a/lib/file.c +++ b/lib/file.c @@ -210,7 +210,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done) Curl_reset_reqproto(conn); if(!data->state.proto.file) { - file = calloc(sizeof(struct FILEPROTO), 1); + file = calloc(1, sizeof(struct FILEPROTO)); if(!file) { free(real_path); return CURLE_OUT_OF_MEMORY; diff --git a/lib/formdata.c b/lib/formdata.c index f2d556ff2..98058a5fa 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -172,7 +172,7 @@ AddHttpPost(char *name, size_t namelength, struct curl_httppost **last_post) { struct curl_httppost *post; - post = calloc(sizeof(struct curl_httppost), 1); + post = calloc(1, sizeof(struct curl_httppost)); if(post) { post->name = name; post->namelength = (long)(name?(namelength?namelength:strlen(name)):0); @@ -223,7 +223,7 @@ static FormInfo * AddFormInfo(char *value, FormInfo *parent_form_info) { FormInfo *form_info; - form_info = calloc(sizeof(FormInfo), 1); + form_info = calloc(1, sizeof(struct FormInfo)); if(form_info) { if(value) form_info->value = value; @@ -411,7 +411,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, /* * We need to allocate the first struct to fill in. */ - first_form = calloc(sizeof(struct FormInfo), 1); + first_form = calloc(1, sizeof(struct FormInfo)); if(!first_form) return CURL_FORMADD_MEMORY; diff --git a/lib/ftp.c b/lib/ftp.c index 14d4b929f..ff2a828d3 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -3092,7 +3092,7 @@ static CURLcode ftp_init(struct connectdata *conn) struct SessionHandle *data = conn->data; struct FTP *ftp = data->state.proto.ftp; if(!ftp) { - ftp = data->state.proto.ftp = calloc(sizeof(struct FTP), 1); + ftp = data->state.proto.ftp = calloc(1, sizeof(struct FTP)); if(!ftp) return CURLE_OUT_OF_MEMORY; } diff --git a/lib/hostip.c b/lib/hostip.c index b21f24175..26ed7b667 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -341,7 +341,7 @@ Curl_cache_addr(struct SessionHandle *data, entry_len = strlen(entry_id); /* Create a new cache entry */ - dns = calloc(sizeof(struct Curl_dns_entry), 1); + dns = calloc(1, sizeof(struct Curl_dns_entry)); if(!dns) { free(entry_id); return NULL; diff --git a/lib/hostip4.c b/lib/hostip4.c index 847b77a18..c10df461c 100644 --- a/lib/hostip4.c +++ b/lib/hostip4.c @@ -137,7 +137,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, else { int h_errnop; - buf = calloc(CURL_HOSTENT_SIZE, 1); + buf = calloc(1, CURL_HOSTENT_SIZE); if(!buf) return NULL; /* major failure */ /* diff --git a/lib/hostthre.c b/lib/hostthre.c index 688006d2b..2ff9c4a07 100644 --- a/lib/hostthre.c +++ b/lib/hostthre.c @@ -396,7 +396,7 @@ static bool init_resolve_thread (struct connectdata *conn, const char *hostname, int port, const struct addrinfo *hints) { - struct thread_data *td = calloc(sizeof(*td), 1); + struct thread_data *td = calloc(1, sizeof(struct thread_data)); HANDLE thread_and_event[2] = {0}; if(!td) { diff --git a/lib/http.c b/lib/http.c index 832a6d507..7e4e58795 100644 --- a/lib/http.c +++ b/lib/http.c @@ -984,7 +984,7 @@ static CURLcode static send_buffer *add_buffer_init(void) { - return calloc(sizeof(send_buffer), 1); + return calloc(1, sizeof(send_buffer)); } /* @@ -2078,7 +2078,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(!data->state.proto.http) { /* Only allocate this struct if we don't already have it! */ - http = calloc(sizeof(struct HTTP), 1); + http = calloc(1, sizeof(struct HTTP)); if(!http) return CURLE_OUT_OF_MEMORY; data->state.proto.http = http; diff --git a/lib/ldap.c b/lib/ldap.c index 4ae304cf3..0152e668c 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -673,7 +673,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp) static int _ldap_url_parse (const struct connectdata *conn, LDAPURLDesc **ludpp) { - LDAPURLDesc *ludp = calloc(sizeof(*ludp), 1); + LDAPURLDesc *ludp = calloc(1, sizeof(*ludp)); int rc; *ludpp = NULL; diff --git a/lib/multi.c b/lib/multi.c index 3525af65b..2210c2fa9 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -282,7 +282,7 @@ static struct Curl_sh_entry *sh_addentry(struct curl_hash *sh, return there; /* not present, add it */ - check = calloc(sizeof(struct Curl_sh_entry), 1); + check = calloc(1, sizeof(struct Curl_sh_entry)); if(!check) return NULL; /* major failure */ check->easy = data; @@ -364,7 +364,7 @@ static struct curl_hash *sh_init(void) CURLM *curl_multi_init(void) { - struct Curl_multi *multi = calloc(sizeof(struct Curl_multi), 1); + struct Curl_multi *multi = calloc(1, sizeof(struct Curl_multi)); if(!multi) return NULL; @@ -425,7 +425,7 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle, return CURLM_BAD_EASY_HANDLE; /* Now, time to add an easy handle to the multi stack */ - easy = calloc(sizeof(struct Curl_one_easy), 1); + easy = calloc(1, sizeof(struct Curl_one_easy)); if(!easy) return CURLM_OUT_OF_MEMORY; @@ -2393,7 +2393,7 @@ static void add_closure(struct Curl_multi *multi, struct SessionHandle *data) { int i; - struct closure *cl = calloc(sizeof(struct closure), 1); + struct closure *cl = calloc(1, sizeof(struct closure)); struct closure *p=NULL; struct closure *n; if(cl) { diff --git a/lib/share.c b/lib/share.c index 9eb8b99b9..5e5866c17 100644 --- a/lib/share.c +++ b/lib/share.c @@ -36,7 +36,7 @@ CURLSH * curl_share_init(void) { - struct Curl_share *share = calloc(sizeof(struct Curl_share), 1); + struct Curl_share *share = calloc(1, sizeof(struct Curl_share)); if(share) share->specifier |= (1<state.proto.ssh) return CURLE_OK; - ssh = calloc(sizeof(struct SSHPROTO), 1); + ssh = calloc(1, sizeof(struct SSHPROTO)); if(!ssh) return CURLE_OUT_OF_MEMORY; diff --git a/lib/sslgen.c b/lib/sslgen.c index 6352224f1..2271eb589 100644 --- a/lib/sslgen.c +++ b/lib/sslgen.c @@ -446,7 +446,7 @@ CURLcode Curl_ssl_initsessions(struct SessionHandle *data, long amount) /* this is just a precaution to prevent multiple inits */ return CURLE_OK; - session = calloc(sizeof(struct curl_ssl_session), amount); + session = calloc(amount, sizeof(struct curl_ssl_session)); if(!session) return CURLE_OUT_OF_MEMORY; diff --git a/lib/ssluse.c b/lib/ssluse.c index ff043c651..9a47e447b 100644 --- a/lib/ssluse.c +++ b/lib/ssluse.c @@ -1966,7 +1966,7 @@ static int init_certinfo(struct SessionHandle *data, Curl_ssl_free_certinfo(data); ci->num_of_certs = num; - table = calloc(sizeof(struct curl_slist *) * num, 1); + table = calloc((size_t)num, sizeof(struct curl_slist *)); if(!table) return 1; diff --git a/lib/tftp.c b/lib/tftp.c index fe55e9dfc..9b8595732 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -838,7 +838,7 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done) sessionhandle, deal with it */ Curl_reset_reqproto(conn); - state = conn->proto.tftpc = calloc(sizeof(tftp_state_data_t), 1); + state = conn->proto.tftpc = calloc(1, sizeof(tftp_state_data_t)); if(!state) return CURLE_OUT_OF_MEMORY; diff --git a/src/urlglob.c b/src/urlglob.c index afbb66ca5..a849b2b87 100644 --- a/src/urlglob.c +++ b/src/urlglob.c @@ -343,7 +343,7 @@ int glob_url(URLGlob** glob, char* url, int *urlnum, FILE *error) if(NULL == glob_buffer) return CURLE_OUT_OF_MEMORY; - glob_expand = calloc(sizeof(URLGlob), 1); + glob_expand = calloc(1, sizeof(URLGlob)); if(NULL == glob_expand) { free(glob_buffer); return CURLE_OUT_OF_MEMORY;