remove unnecessary typecasting of calloc()

This commit is contained in:
Yang Tse 2008-09-06 04:47:14 +00:00
parent 861b647e7b
commit a622fd90b4
15 changed files with 25 additions and 27 deletions

View File

@ -190,7 +190,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 = (struct Cookie *)calloc(sizeof(struct Cookie), 1); co = calloc(sizeof(struct Cookie), 1);
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 */
@ -683,7 +683,7 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
if(NULL == inc) { if(NULL == inc) {
/* we didn't get a struct, create one */ /* we didn't get a struct, create one */
c = (struct CookieInfo *)calloc(1, sizeof(struct CookieInfo)); c = calloc(1, sizeof(struct CookieInfo));
if(!c) if(!c)
return NULL; /* failed to get memory */ return NULL; /* failed to get memory */
c->filename = strdup(file?file:"none"); /* copy the name just in case */ c->filename = strdup(file?file:"none"); /* copy the name just in case */

View File

@ -600,8 +600,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 = (struct SessionHandle *) struct SessionHandle *outcurl = calloc(sizeof(struct SessionHandle), 1);
calloc(sizeof(struct SessionHandle), 1);
if(NULL == outcurl) if(NULL == outcurl)
return NULL; /* failure */ return NULL; /* failure */

View File

@ -202,7 +202,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 = (struct FILEPROTO *)calloc(sizeof(struct FILEPROTO), 1); file = calloc(sizeof(struct FILEPROTO), 1);
if(!file) { if(!file) {
free(real_path); free(real_path);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;

View File

@ -171,7 +171,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 = (struct curl_httppost *)calloc(sizeof(struct curl_httppost), 1); post = calloc(sizeof(struct curl_httppost), 1);
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);
@ -410,7 +410,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 = (FormInfo *)calloc(sizeof(struct FormInfo), 1); first_form = calloc(sizeof(struct FormInfo), 1);
if(!first_form) if(!first_form)
return CURL_FORMADD_MEMORY; return CURL_FORMADD_MEMORY;

View File

@ -3022,7 +3022,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 = (struct FTP *)calloc(sizeof(struct FTP), 1); ftp = calloc(sizeof(struct FTP), 1);
if(!ftp) if(!ftp)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
@ -3905,7 +3905,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
} }
slash_pos=strrchr(cur_pos, '/'); slash_pos=strrchr(cur_pos, '/');
if(slash_pos || !*cur_pos) { if(slash_pos || !*cur_pos) {
ftpc->dirs = (char **)calloc(1, sizeof(ftpc->dirs[0])); ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0]));
if(!ftpc->dirs) if(!ftpc->dirs)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
@ -3927,7 +3927,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
case FTPFILE_MULTICWD: case FTPFILE_MULTICWD:
ftpc->dirdepth = 0; ftpc->dirdepth = 0;
ftpc->diralloc = 5; /* default dir depth to allocate */ ftpc->diralloc = 5; /* default dir depth to allocate */
ftpc->dirs = (char **)calloc(ftpc->diralloc, sizeof(ftpc->dirs[0])); ftpc->dirs = calloc(ftpc->diralloc, sizeof(ftpc->dirs[0]));
if(!ftpc->dirs) if(!ftpc->dirs)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;

View File

@ -332,7 +332,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 = (struct Curl_dns_entry *) calloc(sizeof(struct Curl_dns_entry), 1); dns = calloc(sizeof(struct Curl_dns_entry), 1);
if(!dns) { if(!dns) {
free(entry_id); free(entry_id);
return NULL; return NULL;

View File

@ -150,7 +150,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
else { else {
int h_errnop; int h_errnop;
buf = (struct hostent *)calloc(CURL_HOSTENT_SIZE, 1); buf = calloc(CURL_HOSTENT_SIZE, 1);
if(!buf) if(!buf)
return NULL; /* major failure */ return NULL; /* major failure */
/* /*

View File

@ -2063,7 +2063,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 = (struct HTTP *)calloc(sizeof(struct HTTP), 1); http = calloc(sizeof(struct HTTP), 1);
if(!http) if(!http)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
data->state.proto.http = http; data->state.proto.http = http;

View File

@ -358,7 +358,7 @@ static struct curl_hash *sh_init(void)
CURLM *curl_multi_init(void) CURLM *curl_multi_init(void)
{ {
struct Curl_multi *multi = (void *)calloc(sizeof(struct Curl_multi), 1); struct Curl_multi *multi = calloc(sizeof(struct Curl_multi), 1);
if(!multi) if(!multi)
return NULL; return NULL;
@ -419,7 +419,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 = (struct Curl_one_easy *)calloc(sizeof(struct Curl_one_easy), 1); easy = calloc(sizeof(struct Curl_one_easy), 1);
if(!easy) if(!easy)
return CURLM_OUT_OF_MEMORY; return CURLM_OUT_OF_MEMORY;
@ -2181,7 +2181,7 @@ static void add_closure(struct Curl_multi *multi,
struct SessionHandle *data) struct SessionHandle *data)
{ {
int i; int i;
struct closure *cl = (struct closure *)calloc(sizeof(struct closure), 1); struct closure *cl = calloc(sizeof(struct closure), 1);
struct closure *p=NULL; struct closure *p=NULL;
struct closure *n; struct closure *n;
if(cl) { if(cl) {

View File

@ -1461,7 +1461,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn)
else { else {
sshc->readdir_currLen = strlen(sshc->readdir_longentry); sshc->readdir_currLen = strlen(sshc->readdir_longentry);
sshc->readdir_totalLen = 80 + sshc->readdir_currLen; sshc->readdir_totalLen = 80 + sshc->readdir_currLen;
sshc->readdir_line = (char *)calloc(sshc->readdir_totalLen, 1); sshc->readdir_line = calloc(sshc->readdir_totalLen, 1);
if(!sshc->readdir_line) { if(!sshc->readdir_line) {
Curl_safefree(sshc->readdir_filename); Curl_safefree(sshc->readdir_filename);
sshc->readdir_filename = NULL; sshc->readdir_filename = NULL;
@ -2021,7 +2021,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 = (struct SSHPROTO *)calloc(sizeof(struct SSHPROTO), 1); ssh = calloc(sizeof(struct SSHPROTO), 1);
if(!ssh) if(!ssh)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;

View File

@ -428,8 +428,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 = (struct curl_ssl_session *) session = calloc(sizeof(struct curl_ssl_session), amount);
calloc(sizeof(struct curl_ssl_session), amount);
if(!session) if(!session)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;

View File

@ -241,7 +241,7 @@ CURLcode init_telnet(struct connectdata *conn)
{ {
struct TELNET *tn; struct TELNET *tn;
tn = (struct TELNET *)calloc(1, sizeof(struct TELNET)); tn = calloc(1, sizeof(struct TELNET));
if(!tn) if(!tn)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;

View File

@ -651,7 +651,7 @@ CURLcode Curl_open(struct SessionHandle **curl)
#endif #endif
/* Very simple start-up: alloc the struct, init it with zeroes and return */ /* Very simple start-up: alloc the struct, init it with zeroes and return */
data = (struct SessionHandle *)calloc(1, sizeof(struct SessionHandle)); data = calloc(1, sizeof(struct SessionHandle));
if(!data) { if(!data) {
/* this is a very serious error */ /* this is a very serious error */
DEBUGF(fprintf(stderr, "Error: calloc of SessionHandle failed\n")); DEBUGF(fprintf(stderr, "Error: calloc of SessionHandle failed\n"));
@ -2969,7 +2969,7 @@ static struct connectdata *allocate_conn(void)
{ {
struct connectdata *conn; struct connectdata *conn;
conn = (struct connectdata *)calloc(1, sizeof(struct connectdata)); conn = calloc(1, sizeof(struct connectdata));
if(!conn) if(!conn)
return NULL; return NULL;

View File

@ -192,7 +192,7 @@ buffer_threaded(localkey_t key, long size)
/* Allocate buffer descriptors for the current thread. */ /* Allocate buffer descriptors for the current thread. */
if (!(bufs = (buffer_t *) calloc((size_t) LK_LAST, sizeof *bufs))) if (!(bufs = calloc((size_t) LK_LAST, sizeof *bufs)))
return (char *) NULL; return (char *) NULL;
if (pthread_setspecific(thdkey, (void *) bufs)) { if (pthread_setspecific(thdkey, (void *) bufs)) {
@ -220,7 +220,7 @@ buffer_undef(localkey_t key, long size)
if (Curl_thread_buffer == buffer_undef) { /* If unchanged during lock. */ if (Curl_thread_buffer == buffer_undef) { /* If unchanged during lock. */
if (!pthread_key_create(&thdkey, thdbufdestroy)) if (!pthread_key_create(&thdkey, thdbufdestroy))
Curl_thread_buffer = buffer_threaded; Curl_thread_buffer = buffer_threaded;
else if (!(locbufs = (buffer_t *) calloc((size_t) LK_LAST, else if (!(locbufs = calloc((size_t) LK_LAST,
sizeof *locbufs))) { sizeof *locbufs))) {
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return (char *) NULL; return (char *) NULL;
@ -777,7 +777,7 @@ Curl_ldap_search_s_a(void * ld, char * base, int scope, char * filter,
for (i = 0; attrs[i++];) for (i = 0; attrs[i++];)
; ;
if (!(eattrs = (char * *) calloc(i, sizeof *eattrs))) if (!(eattrs = calloc(i, sizeof *eattrs)))
status = LDAP_NO_MEMORY; status = LDAP_NO_MEMORY;
else { else {
for (j = 0; attrs[j]; j++) { for (j = 0; attrs[j]; j++) {

View File

@ -341,7 +341,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 = (URLGlob*)calloc(sizeof(URLGlob), 1); glob_expand = calloc(sizeof(URLGlob), 1);
if(NULL == glob_expand) { if(NULL == glob_expand) {
free(glob_buffer); free(glob_buffer);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;