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 */
|
return ARES_SUCCESS; /* use localhost DNS server */
|
||||||
|
|
||||||
nservers = i;
|
nservers = i;
|
||||||
servers = calloc(sizeof(*servers), i);
|
servers = calloc(i, sizeof(struct server_state));
|
||||||
if (!servers)
|
if (!servers)
|
||||||
return ARES_ENOMEM;
|
return ARES_ENOMEM;
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ void ares__send_query(ares_channel channel, struct query *query,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendreq = calloc(sizeof(struct send_request), 1);
|
sendreq = calloc(1, sizeof(struct send_request));
|
||||||
if (!sendreq)
|
if (!sendreq)
|
||||||
{
|
{
|
||||||
end_query(channel, query, ARES_ENOMEM, NULL, 0);
|
end_query(channel, query, ARES_ENOMEM, NULL, 0);
|
||||||
|
@ -204,7 +204,7 @@ Curl_cookie_add(struct SessionHandle *data,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* First, alloc and init a new struct for it */
|
/* First, alloc and init a new struct for it */
|
||||||
co = calloc(sizeof(struct Cookie), 1);
|
co = calloc(1, sizeof(struct Cookie));
|
||||||
if(!co)
|
if(!co)
|
||||||
return NULL; /* bail out if we're this low on memory */
|
return NULL; /* bail out if we're this low on memory */
|
||||||
|
|
||||||
|
@ -619,7 +619,7 @@ CURL *curl_easy_duphandle(CURL *incurl)
|
|||||||
bool fail = TRUE;
|
bool fail = TRUE;
|
||||||
struct SessionHandle *data=(struct SessionHandle *)incurl;
|
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)
|
if(NULL == outcurl)
|
||||||
return NULL; /* failure */
|
return NULL; /* failure */
|
||||||
|
@ -210,7 +210,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
|
|||||||
Curl_reset_reqproto(conn);
|
Curl_reset_reqproto(conn);
|
||||||
|
|
||||||
if(!data->state.proto.file) {
|
if(!data->state.proto.file) {
|
||||||
file = calloc(sizeof(struct FILEPROTO), 1);
|
file = calloc(1, sizeof(struct FILEPROTO));
|
||||||
if(!file) {
|
if(!file) {
|
||||||
free(real_path);
|
free(real_path);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
@ -172,7 +172,7 @@ AddHttpPost(char *name, size_t namelength,
|
|||||||
struct curl_httppost **last_post)
|
struct curl_httppost **last_post)
|
||||||
{
|
{
|
||||||
struct curl_httppost *post;
|
struct curl_httppost *post;
|
||||||
post = calloc(sizeof(struct curl_httppost), 1);
|
post = calloc(1, sizeof(struct curl_httppost));
|
||||||
if(post) {
|
if(post) {
|
||||||
post->name = name;
|
post->name = name;
|
||||||
post->namelength = (long)(name?(namelength?namelength:strlen(name)):0);
|
post->namelength = (long)(name?(namelength?namelength:strlen(name)):0);
|
||||||
@ -223,7 +223,7 @@ static FormInfo * AddFormInfo(char *value,
|
|||||||
FormInfo *parent_form_info)
|
FormInfo *parent_form_info)
|
||||||
{
|
{
|
||||||
FormInfo *form_info;
|
FormInfo *form_info;
|
||||||
form_info = calloc(sizeof(FormInfo), 1);
|
form_info = calloc(1, sizeof(struct FormInfo));
|
||||||
if(form_info) {
|
if(form_info) {
|
||||||
if(value)
|
if(value)
|
||||||
form_info->value = 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.
|
* 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)
|
if(!first_form)
|
||||||
return CURL_FORMADD_MEMORY;
|
return CURL_FORMADD_MEMORY;
|
||||||
|
|
||||||
|
@ -3092,7 +3092,7 @@ static CURLcode ftp_init(struct connectdata *conn)
|
|||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
struct FTP *ftp = data->state.proto.ftp;
|
struct FTP *ftp = data->state.proto.ftp;
|
||||||
if(!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)
|
if(!ftp)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ Curl_cache_addr(struct SessionHandle *data,
|
|||||||
entry_len = strlen(entry_id);
|
entry_len = strlen(entry_id);
|
||||||
|
|
||||||
/* Create a new cache entry */
|
/* Create a new cache entry */
|
||||||
dns = calloc(sizeof(struct Curl_dns_entry), 1);
|
dns = calloc(1, sizeof(struct Curl_dns_entry));
|
||||||
if(!dns) {
|
if(!dns) {
|
||||||
free(entry_id);
|
free(entry_id);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -137,7 +137,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
else {
|
else {
|
||||||
int h_errnop;
|
int h_errnop;
|
||||||
|
|
||||||
buf = calloc(CURL_HOSTENT_SIZE, 1);
|
buf = calloc(1, CURL_HOSTENT_SIZE);
|
||||||
if(!buf)
|
if(!buf)
|
||||||
return NULL; /* major failure */
|
return NULL; /* major failure */
|
||||||
/*
|
/*
|
||||||
|
@ -396,7 +396,7 @@ static bool init_resolve_thread (struct connectdata *conn,
|
|||||||
const char *hostname, int port,
|
const char *hostname, int port,
|
||||||
const struct addrinfo *hints)
|
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};
|
HANDLE thread_and_event[2] = {0};
|
||||||
|
|
||||||
if(!td) {
|
if(!td) {
|
||||||
|
@ -984,7 +984,7 @@ static CURLcode
|
|||||||
static
|
static
|
||||||
send_buffer *add_buffer_init(void)
|
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) {
|
if(!data->state.proto.http) {
|
||||||
/* Only allocate this struct if we don't already have it! */
|
/* 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)
|
if(!http)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
data->state.proto.http = http;
|
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,
|
static int _ldap_url_parse (const struct connectdata *conn,
|
||||||
LDAPURLDesc **ludpp)
|
LDAPURLDesc **ludpp)
|
||||||
{
|
{
|
||||||
LDAPURLDesc *ludp = calloc(sizeof(*ludp), 1);
|
LDAPURLDesc *ludp = calloc(1, sizeof(*ludp));
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
*ludpp = NULL;
|
*ludpp = NULL;
|
||||||
|
@ -282,7 +282,7 @@ static struct Curl_sh_entry *sh_addentry(struct curl_hash *sh,
|
|||||||
return there;
|
return there;
|
||||||
|
|
||||||
/* not present, add it */
|
/* not present, add it */
|
||||||
check = calloc(sizeof(struct Curl_sh_entry), 1);
|
check = calloc(1, sizeof(struct Curl_sh_entry));
|
||||||
if(!check)
|
if(!check)
|
||||||
return NULL; /* major failure */
|
return NULL; /* major failure */
|
||||||
check->easy = data;
|
check->easy = data;
|
||||||
@ -364,7 +364,7 @@ static struct curl_hash *sh_init(void)
|
|||||||
|
|
||||||
CURLM *curl_multi_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)
|
if(!multi)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -425,7 +425,7 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
|
|||||||
return CURLM_BAD_EASY_HANDLE;
|
return CURLM_BAD_EASY_HANDLE;
|
||||||
|
|
||||||
/* Now, time to add an easy handle to the multi stack */
|
/* 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)
|
if(!easy)
|
||||||
return CURLM_OUT_OF_MEMORY;
|
return CURLM_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@ -2393,7 +2393,7 @@ static void add_closure(struct Curl_multi *multi,
|
|||||||
struct SessionHandle *data)
|
struct SessionHandle *data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct closure *cl = calloc(sizeof(struct closure), 1);
|
struct closure *cl = calloc(1, sizeof(struct closure));
|
||||||
struct closure *p=NULL;
|
struct closure *p=NULL;
|
||||||
struct closure *n;
|
struct closure *n;
|
||||||
if(cl) {
|
if(cl) {
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
CURLSH *
|
CURLSH *
|
||||||
curl_share_init(void)
|
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)
|
if(share)
|
||||||
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
|
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
|
||||||
|
|
||||||
|
@ -2383,7 +2383,7 @@ static CURLcode ssh_init(struct connectdata *conn)
|
|||||||
if(data->state.proto.ssh)
|
if(data->state.proto.ssh)
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
ssh = calloc(sizeof(struct SSHPROTO), 1);
|
ssh = calloc(1, sizeof(struct SSHPROTO));
|
||||||
if(!ssh)
|
if(!ssh)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
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 */
|
/* this is just a precaution to prevent multiple inits */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
session = calloc(sizeof(struct curl_ssl_session), amount);
|
session = calloc(amount, sizeof(struct curl_ssl_session));
|
||||||
if(!session)
|
if(!session)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -1966,7 +1966,7 @@ static int init_certinfo(struct SessionHandle *data,
|
|||||||
Curl_ssl_free_certinfo(data);
|
Curl_ssl_free_certinfo(data);
|
||||||
|
|
||||||
ci->num_of_certs = num;
|
ci->num_of_certs = num;
|
||||||
table = calloc(sizeof(struct curl_slist *) * num, 1);
|
table = calloc((size_t)num, sizeof(struct curl_slist *));
|
||||||
if(!table)
|
if(!table)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -838,7 +838,7 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done)
|
|||||||
sessionhandle, deal with it */
|
sessionhandle, deal with it */
|
||||||
Curl_reset_reqproto(conn);
|
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)
|
if(!state)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ int glob_url(URLGlob** glob, char* url, int *urlnum, FILE *error)
|
|||||||
if(NULL == glob_buffer)
|
if(NULL == glob_buffer)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
glob_expand = calloc(sizeof(URLGlob), 1);
|
glob_expand = calloc(1, sizeof(URLGlob));
|
||||||
if(NULL == glob_expand) {
|
if(NULL == glob_expand) {
|
||||||
free(glob_buffer);
|
free(glob_buffer);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
Loading…
Reference in New Issue
Block a user