mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Make usage of calloc()'s arguments consistent with rest of code base
This commit is contained in:
parent
961c504ca5
commit
59939313f8
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
/*
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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<<CURL_LOCK_DATA_SHARE);
|
||||
|
||||
|
@ -2383,7 +2383,7 @@ static CURLcode ssh_init(struct connectdata *conn)
|
||||
if(data->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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user