diff options
author | Yang Tse <yangsita@gmail.com> | 2008-09-06 05:29:05 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2008-09-06 05:29:05 +0000 |
commit | 59e378f48fed849e8e41f0bc6a10bf7a1732ae8a (patch) | |
tree | 2443ceace655d5d830c7c4d7c95869c6a0f93c5c /lib | |
parent | a622fd90b4c563a4fced20c5b88cb57537e809b0 (diff) |
remove unnecessary typecasting of malloc()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base64.c | 4 | ||||
-rw-r--r-- | lib/content_encoding.c | 2 | ||||
-rw-r--r-- | lib/cookie.c | 4 | ||||
-rw-r--r-- | lib/easy.c | 2 | ||||
-rw-r--r-- | lib/formdata.c | 11 | ||||
-rw-r--r-- | lib/ftp.c | 4 | ||||
-rw-r--r-- | lib/hash.c | 7 | ||||
-rw-r--r-- | lib/http.c | 4 | ||||
-rw-r--r-- | lib/http_chunks.c | 2 | ||||
-rw-r--r-- | lib/http_digest.c | 2 | ||||
-rw-r--r-- | lib/llist.c | 5 | ||||
-rw-r--r-- | lib/mprintf.c | 2 | ||||
-rw-r--r-- | lib/multi.c | 2 | ||||
-rw-r--r-- | lib/nss.c | 18 | ||||
-rw-r--r-- | lib/nwlib.c | 4 | ||||
-rw-r--r-- | lib/sendf.c | 2 | ||||
-rw-r--r-- | lib/share.c | 3 | ||||
-rw-r--r-- | lib/splay.c | 2 | ||||
-rw-r--r-- | lib/ssh.c | 12 | ||||
-rw-r--r-- | lib/strdup.c | 2 | ||||
-rw-r--r-- | lib/transfer.c | 2 | ||||
-rw-r--r-- | lib/url.c | 6 |
22 files changed, 49 insertions, 53 deletions
diff --git a/lib/base64.c b/lib/base64.c index 0453624fb..37591f00c 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -160,7 +160,7 @@ size_t Curl_base64_encode(struct SessionHandle *data, if(0 == insize) insize = strlen(indata); - base64data = output = (char*)malloc(insize*4/3+4); + base64data = output = malloc(insize*4/3+4); if(NULL == output) return 0; @@ -171,7 +171,7 @@ size_t Curl_base64_encode(struct SessionHandle *data, * so we copy it to a buffer, translate it, and use that instead. */ if(data) { - convbuf = (char*)malloc(insize); + convbuf = malloc(insize); if(!convbuf) { free(output); return 0; diff --git a/lib/content_encoding.c b/lib/content_encoding.c index 1d2852b5a..9cd5b0734 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -89,7 +89,7 @@ inflate_stream(struct connectdata *conn, /* Dynamically allocate a buffer for decompression because it's uncommonly large to hold on the stack */ - decomp = (char*)malloc(DSIZ); + decomp = malloc(DSIZ); if(decomp == NULL) { return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY); } diff --git a/lib/cookie.c b/lib/cookie.c index fada612dd..59df3b64f 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -711,7 +711,7 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, char *lineptr; bool headerline; - char *line = (char *)malloc(MAX_COOKIE_LINE); + char *line = malloc(MAX_COOKIE_LINE); if(line) { while(fgets(line, MAX_COOKIE_LINE, fp)) { if(checkprefix("Set-Cookie:", line)) { @@ -789,7 +789,7 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c, /* and now, we know this is a match and we should create an entry for the return-linked-list */ - newco = (struct Cookie *)malloc(sizeof(struct Cookie)); + newco = malloc(sizeof(struct Cookie)); if(newco) { /* first, copy the whole source cookie: */ memcpy(newco, co, sizeof(struct Cookie)); diff --git a/lib/easy.c b/lib/easy.c index 1dba68c8f..4e4998297 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -612,7 +612,7 @@ CURL *curl_easy_duphandle(CURL *incurl) * get setup on-demand in the code, as that would probably decrease * the likeliness of us forgetting to init a buffer here in the future. */ - outcurl->state.headerbuff=(char*)malloc(HEADERSIZE); + outcurl->state.headerbuff = malloc(HEADERSIZE); if(!outcurl->state.headerbuff) { break; } diff --git a/lib/formdata.c b/lib/formdata.c index 2ab1d1af1..e017cb7f3 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -222,7 +222,7 @@ static FormInfo * AddFormInfo(char *value, FormInfo *parent_form_info) { FormInfo *form_info; - form_info = (FormInfo *)malloc(sizeof(FormInfo)); + form_info = malloc(sizeof(FormInfo)); if(form_info) { memset(form_info, 0, sizeof(FormInfo)); if(value) @@ -327,7 +327,7 @@ static char *memdup(const char *src, size_t buffer_length) /* no length and a NULL src pointer! */ return strdup(""); - buffer = (char*)malloc(length+add); + buffer = malloc(length+add); if(!buffer) return NULL; /* fail */ @@ -838,8 +838,7 @@ static CURLcode AddFormData(struct FormData **formp, size_t length, curl_off_t *size) { - struct FormData *newform = (struct FormData *) - malloc(sizeof(struct FormData)); + struct FormData *newform = malloc(sizeof(struct FormData)); if(!newform) return CURLE_OUT_OF_MEMORY; newform->next = NULL; @@ -849,7 +848,7 @@ static CURLcode AddFormData(struct FormData **formp, if(!length) length = strlen((char *)line); - newform->line = (char *)malloc(length+1); + newform->line = malloc(length+1); if(!newform->line) { free(newform); return CURLE_OUT_OF_MEMORY; @@ -1729,7 +1728,7 @@ char *Curl_FormBoundary(void) static const char table16[]="abcdef0123456789"; - retstring = (char *)malloc(BOUNDARY_LENGTH+1); + retstring = malloc(BOUNDARY_LENGTH+1); if(!retstring) return NULL; /* failed */ @@ -550,7 +550,7 @@ static CURLcode ftp_readresp(curl_socket_t sockfd, if(clipamount) { ftpc->cache_size = clipamount; - ftpc->cache = (char *)malloc((int)ftpc->cache_size); + ftpc->cache = malloc((int)ftpc->cache_size); if(ftpc->cache) memcpy(ftpc->cache, ftpc->linestart_resp, (int)ftpc->cache_size); else @@ -2751,7 +2751,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) case FTP_PWD: if(ftpcode == 257) { - char *dir = (char *)malloc(nread+1); + char *dir = malloc(nread+1); char *store=dir; char *ptr=&data->state.buffer[4]; /* start on the first letter */ diff --git a/lib/hash.c b/lib/hash.c index 8496803bb..095fa7028 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -67,7 +67,7 @@ Curl_hash_init(struct curl_hash *h, h->size = 0; h->slots = slots; - h->table = (struct curl_llist **) malloc(slots * sizeof(struct curl_llist *)); + h->table = malloc(slots * sizeof(struct curl_llist *)); if(h->table) { for (i = 0; i < slots; ++i) { h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor); @@ -96,7 +96,7 @@ Curl_hash_alloc(int slots, return NULL; /* failure */ } - h = (struct curl_hash *) malloc(sizeof(struct curl_hash)); + h = malloc(sizeof(struct curl_hash)); if(h) { if(Curl_hash_init(h, slots, hfunc, comparator, dtor)) { /* failure */ @@ -113,8 +113,7 @@ Curl_hash_alloc(int slots, static struct curl_hash_element * mk_hash_element(const void *key, size_t key_len, const void *p) { - struct curl_hash_element *he = - (struct curl_hash_element *) malloc(sizeof(struct curl_hash_element)); + struct curl_hash_element *he = malloc(sizeof(struct curl_hash_element)); if(he) { void *dupkey = malloc(key_len); diff --git a/lib/http.c b/lib/http.c index 6b22c2c10..e223c1f92 100644 --- a/lib/http.c +++ b/lib/http.c @@ -971,7 +971,7 @@ static send_buffer *add_buffer_init(void) { send_buffer *blonk; - blonk=(send_buffer *)malloc(sizeof(send_buffer)); + blonk = malloc(sizeof(send_buffer)); if(blonk) { memset(blonk, 0, sizeof(send_buffer)); return blonk; @@ -1193,7 +1193,7 @@ CURLcode add_buffer(send_buffer *in, const void *inptr, size_t size) new_rb = realloc(in->buffer, new_size); else /* create a new buffer */ - new_rb = (char *)malloc(new_size); + new_rb = malloc(new_size); if(!new_rb) { /* If we failed, we cleanup the whole buffer and return error */ diff --git a/lib/http_chunks.c b/lib/http_chunks.c index 45199866f..0d72793ce 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -309,7 +309,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, } else { conn->trlMax=128; - ptr = (char*)malloc(conn->trlMax); + ptr = malloc(conn->trlMax); } if(!ptr) return CHUNKE_OUT_OF_MEMORY; diff --git a/lib/http_digest.c b/lib/http_digest.c index a3c2ad7d7..81e8612a7 100644 --- a/lib/http_digest.c +++ b/lib/http_digest.c @@ -320,7 +320,7 @@ CURLcode Curl_output_digest(struct connectdata *conn, Curl_md5it(md5buf, md5this); free(md5this); /* free this again */ - ha1 = (unsigned char *)malloc(33); /* 32 digits and 1 zero byte */ + ha1 = malloc(33); /* 32 digits and 1 zero byte */ if(!ha1) return CURLE_OUT_OF_MEMORY; diff --git a/lib/llist.c b/lib/llist.c index 43d46233e..cd9edad63 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -46,7 +46,7 @@ Curl_llist_alloc(curl_llist_dtor dtor) { struct curl_llist *list; - list = (struct curl_llist *)malloc(sizeof(struct curl_llist)); + list = malloc(sizeof(struct curl_llist)); if(NULL == list) return NULL; @@ -62,8 +62,7 @@ int Curl_llist_insert_next(struct curl_llist *list, struct curl_llist_element *e, const void *p) { - struct curl_llist_element *ne = - (struct curl_llist_element *) malloc(sizeof(struct curl_llist_element)); + struct curl_llist_element *ne = malloc(sizeof(struct curl_llist_element)); if(!ne) return 0; diff --git a/lib/mprintf.c b/lib/mprintf.c index 255eb11df..46438d47d 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -1068,7 +1068,7 @@ static int alloc_addbyter(int output, FILE *data) unsigned char outc = (unsigned char)output; if(!infop->buffer) { - infop->buffer=(char *)malloc(32); + infop->buffer = malloc(32); if(!infop->buffer) { infop->fail = 1; return -1; /* fail */ diff --git a/lib/multi.c b/lib/multi.c index acf43a204..f8602e1d6 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -1427,7 +1427,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } /* now add a node to the Curl_message linked list with this info */ - msg = (struct Curl_message *)malloc(sizeof(struct Curl_message)); + msg = malloc(sizeof(struct Curl_message)); if(!msg) return CURLM_OUT_OF_MEMORY; @@ -298,8 +298,8 @@ nss_load_cert(const char *filename, PRBool cacert) else slotID = 1; - slotname = (char *)malloc(SLOTSIZE); - nickname = (char *)malloc(PATH_MAX); + slotname = malloc(SLOTSIZE); + nickname = malloc(PATH_MAX); snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID); snprintf(nickname, PATH_MAX, "PEM Token #%ld:%s", slotID, n); @@ -460,7 +460,7 @@ static int nss_load_key(struct connectdata *conn, char *key_file) slotID = 1; /* hardcoded for now */ - slotname = (char *)malloc(SLOTSIZE); + slotname = malloc(SLOTSIZE); snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID); slot = PK11_FindSlotByName(slotname); @@ -485,7 +485,7 @@ static int nss_load_key(struct connectdata *conn, char *key_file) SECMOD_WaitForAnyTokenEvent(mod, 0, 0); PK11_IsPresent(slot); - parg = (pphrase_arg_t *) malloc(sizeof(*parg)); + parg = malloc(sizeof(pphrase_arg_t)); parg->retryCount = 0; parg->data = conn->data; /* parg is initialized in nss_Init_Tokens() */ @@ -581,7 +581,7 @@ static SECStatus nss_Init_Tokens(struct connectdata * conn) SECStatus ret, status = SECSuccess; pphrase_arg_t *parg = NULL; - parg = (pphrase_arg_t *) malloc(sizeof(*parg)); + parg = malloc(sizeof(pphrase_arg_t)); parg->retryCount = 0; parg->data = conn->data; @@ -800,7 +800,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock, if(!strncmp(nickname, "PEM Token", 9)) { CK_SLOT_ID slotID = 1; /* hardcoded for now */ - char * slotname = (char *)malloc(SLOTSIZE); + char * slotname = malloc(SLOTSIZE); snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID); slot = PK11_FindSlotByName(slotname); privKey = PK11_FindPrivateKeyFromCert(slot, cert, NULL); @@ -956,7 +956,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex) NSS_SetDomesticPolicy(); #ifdef HAVE_PK11_CREATEGENERICOBJECT - configstring = (char *)malloc(PATH_MAX); + configstring = malloc(PATH_MAX); PR_snprintf(configstring, PATH_MAX, "library=%s name=PEM", pem_library); @@ -1091,7 +1091,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex) char *n; char *nickname; - nickname = (char *)malloc(PATH_MAX); + nickname = malloc(PATH_MAX); if(is_file(data->set.str[STRING_CERT])) { n = strrchr(data->set.str[STRING_CERT], '/'); if(n) { @@ -1159,7 +1159,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex) if (data->set.str[STRING_SSL_ISSUERCERT]) { char *n; char *nickname; - nickname = (char *)malloc(PATH_MAX); + nickname = malloc(PATH_MAX); if(is_file(data->set.str[STRING_SSL_ISSUERCERT])) { n = strrchr(data->set.str[STRING_SSL_ISSUERCERT], '/'); if (n) { diff --git a/lib/nwlib.c b/lib/nwlib.c index 3a3e28ef8..185042b29 100644 --- a/lib/nwlib.c +++ b/lib/nwlib.c @@ -185,7 +185,7 @@ int GetOrSetUpData(int id, libdata_t **appData, NXLock(gLibLock); if(!(app_data = (libdata_t *) get_app_data(id))) { - app_data = (libdata_t *) malloc(sizeof(libdata_t)); + app_data = malloc(sizeof(libdata_t)); if(app_data) { memset(app_data, 0, sizeof(libdata_t)); @@ -246,7 +246,7 @@ int GetOrSetUpData(int id, libdata_t **appData, ** important, this just helps to demonstrate that we can have arbitrarily ** complex per-thread data. */ - thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t)); + thread_data = malloc(sizeof(libthreaddata_t)); if(thread_data) { thread_data->_errno = 0; diff --git a/lib/sendf.c b/lib/sendf.c index cdab3abdd..568e7b8cd 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -91,7 +91,7 @@ struct curl_slist *curl_slist_append(struct curl_slist *list, struct curl_slist *last; struct curl_slist *new_item; - new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist)); + new_item = malloc(sizeof(struct curl_slist)); if(new_item) { char *dupdata = strdup(data); if(dupdata) { diff --git a/lib/share.c b/lib/share.c index 3a5f072bd..6430611b3 100644 --- a/lib/share.c +++ b/lib/share.c @@ -36,8 +36,7 @@ CURLSH * curl_share_init(void) { - struct Curl_share *share = - (struct Curl_share *)malloc(sizeof(struct Curl_share)); + struct Curl_share *share = malloc(sizeof(struct Curl_share)); if(share) { memset (share, 0, sizeof(struct Curl_share)); share->specifier |= (1<<CURL_LOCK_DATA_SHARE); diff --git a/lib/splay.c b/lib/splay.c index c64ccdaea..de49af0d9 100644 --- a/lib/splay.c +++ b/lib/splay.c @@ -394,7 +394,7 @@ int main(int argc, argv_item_t argv[]) for (i = 0; i < MAX; i++) { struct timeval key; - ptrs[i] = t = (struct Curl_tree *)malloc(sizeof(struct Curl_tree)); + ptrs[i] = t = malloc(sizeof(struct Curl_tree)); key.tv_sec = 0; #ifdef TEST2 @@ -379,7 +379,7 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn, /* Check for /~/ , indicating relative to the user's home directory */ if(conn->protocol & PROT_SCP) { - real_path = (char *)malloc(working_path_len+1); + real_path = malloc(working_path_len+1); if(real_path == NULL) { free(working_path); return CURLE_OUT_OF_MEMORY; @@ -393,7 +393,7 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn, else if(conn->protocol & PROT_SFTP) { if((working_path_len > 1) && (working_path[1] == '~')) { size_t homelen = strlen(homedir); - real_path = (char *)malloc(homelen + working_path_len + 1); + real_path = malloc(homelen + working_path_len + 1); if(real_path == NULL) { free(working_path); return CURLE_OUT_OF_MEMORY; @@ -409,7 +409,7 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn, } } else { - real_path = (char *)malloc(working_path_len+1); + real_path = malloc(working_path_len+1); if(real_path == NULL) { free(working_path); return CURLE_OUT_OF_MEMORY; @@ -1403,12 +1403,12 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) break; } } - if((sshc->readdir_filename = (char *)malloc(PATH_MAX+1)) == NULL) { + if((sshc->readdir_filename = malloc(PATH_MAX+1)) == NULL) { state(conn, SSH_SFTP_CLOSE); sshc->actualcode = CURLE_OUT_OF_MEMORY; break; } - if((sshc->readdir_longentry = (char *)malloc(PATH_MAX+1)) == NULL) { + if((sshc->readdir_longentry = malloc(PATH_MAX+1)) == NULL) { Curl_safefree(sshc->readdir_filename); sshc->readdir_filename = NULL; state(conn, SSH_SFTP_CLOSE); @@ -1477,7 +1477,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) if((sshc->readdir_attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) && ((sshc->readdir_attrs.permissions & LIBSSH2_SFTP_S_IFMT) == LIBSSH2_SFTP_S_IFLNK)) { - sshc->readdir_linkPath = (char *)malloc(PATH_MAX + 1); + sshc->readdir_linkPath = malloc(PATH_MAX + 1); if(sshc->readdir_linkPath == NULL) { Curl_safefree(sshc->readdir_filename); sshc->readdir_filename = NULL; diff --git a/lib/strdup.c b/lib/strdup.c index eef9e08ec..7587285a1 100644 --- a/lib/strdup.c +++ b/lib/strdup.c @@ -38,7 +38,7 @@ char *curlx_strdup(const char *str) if(len >= ((size_t)-1) / sizeof(char)) return (char *)NULL; - newstr = (char *) malloc((len+1)*sizeof(char)); + newstr = malloc((len+1)*sizeof(char)); if(!newstr) return (char *)NULL; diff --git a/lib/transfer.c b/lib/transfer.c index baf7c19e8..2cabc3b4f 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -2136,7 +2136,7 @@ static char *concat_url(const char *base, const char *relurl) urllen = strlen(url_clone); - newest=(char *)malloc( urllen + 1 + /* possible slash */ + newest = malloc( urllen + 1 + /* possible slash */ newlen + 1 /* zero byte */); if(!newest) { @@ -675,7 +675,7 @@ CURLcode Curl_open(struct SessionHandle **curl) /* We do some initial setup here, all those fields that can't be just 0 */ - data->state.headerbuff=(char*)malloc(HEADERSIZE); + data->state.headerbuff = malloc(HEADERSIZE); if(!data->state.headerbuff) { DEBUGF(fprintf(stderr, "Error: malloc of headerbuff failed\n")); res = CURLE_OUT_OF_MEMORY; @@ -4154,12 +4154,12 @@ static CURLcode create_conn(struct SessionHandle *data, */ Curl_safefree(data->state.pathbuffer); - data->state.pathbuffer=(char *)malloc(urllen+2); + data->state.pathbuffer = malloc(urllen+2); if(NULL == data->state.pathbuffer) return CURLE_OUT_OF_MEMORY; /* really bad error */ data->state.path = data->state.pathbuffer; - conn->host.rawalloc=(char *)malloc(urllen+2); + conn->host.rawalloc = malloc(urllen+2); if(NULL == conn->host.rawalloc) return CURLE_OUT_OF_MEMORY; |