mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
remove unnecessary typecasting of realloc()
This commit is contained in:
parent
70e57dad88
commit
861b647e7b
@ -119,7 +119,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
|||||||
strncpy(aliases[aliascnt], rr_data, strlen(rr_data)+1);
|
strncpy(aliases[aliascnt], rr_data, strlen(rr_data)+1);
|
||||||
aliascnt++;
|
aliascnt++;
|
||||||
if ((aliascnt%8)==0)
|
if ((aliascnt%8)==0)
|
||||||
aliases = (char **) realloc(aliases, (aliascnt/16+1) * sizeof(char *));
|
aliases = realloc(aliases, (aliascnt/16+1) * sizeof(char *));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rr_class == C_IN && rr_type == T_CNAME)
|
if (rr_class == C_IN && rr_type == T_CNAME)
|
||||||
|
@ -469,7 +469,7 @@ int main(int argc, char **argv) {
|
|||||||
i+=lu;
|
i+=lu;
|
||||||
if (i== tabLength) {
|
if (i== tabLength) {
|
||||||
tabLength+=100;
|
tabLength+=100;
|
||||||
binaryptr=(char*)realloc(binaryptr,tabLength); /* should be more careful */
|
binaryptr=realloc(binaryptr,tabLength); /* should be more careful */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tabLength = i;
|
tabLength = i;
|
||||||
|
@ -26,6 +26,8 @@ struct MemoryStruct {
|
|||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void *myrealloc(void *ptr, size_t size);
|
||||||
|
|
||||||
static void *myrealloc(void *ptr, size_t size)
|
static void *myrealloc(void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
/* There might be a realloc() out there that doesn't like reallocing
|
/* There might be a realloc() out there that doesn't like reallocing
|
||||||
@ -42,7 +44,7 @@ WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
|
|||||||
size_t realsize = size * nmemb;
|
size_t realsize = size * nmemb;
|
||||||
struct MemoryStruct *mem = (struct MemoryStruct *)data;
|
struct MemoryStruct *mem = (struct MemoryStruct *)data;
|
||||||
|
|
||||||
mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1);
|
mem->memory = myrealloc(mem->memory, mem->size + realsize + 1);
|
||||||
if (mem->memory) {
|
if (mem->memory) {
|
||||||
memcpy(&(mem->memory[mem->size]), ptr, realsize);
|
memcpy(&(mem->memory[mem->size]), ptr, realsize);
|
||||||
mem->size += realsize;
|
mem->size += realsize;
|
||||||
|
@ -356,7 +356,7 @@ void *suck(int *lenptr)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
cursize *= 2;
|
cursize *= 2;
|
||||||
buf = (unsigned char *)realloc(buf, cursize);
|
buf = realloc(buf, cursize);
|
||||||
memset(buf + len, 0, cursize - len);
|
memset(buf + len, 0, cursize - len);
|
||||||
lastread = fread(buf + len, 1, cursize - len, stdin);
|
lastread = fread(buf + len, 1, cursize - len, stdin);
|
||||||
len += lastread;
|
len += lastread;
|
||||||
|
@ -1190,7 +1190,7 @@ CURLcode add_buffer(send_buffer *in, const void *inptr, size_t size)
|
|||||||
|
|
||||||
if(in->buffer)
|
if(in->buffer)
|
||||||
/* we have a buffer, enlarge the existing one */
|
/* we have a buffer, enlarge the existing one */
|
||||||
new_rb = (char *)realloc(in->buffer, new_size);
|
new_rb = realloc(in->buffer, new_size);
|
||||||
else
|
else
|
||||||
/* create a new buffer */
|
/* create a new buffer */
|
||||||
new_rb = (char *)malloc(new_size);
|
new_rb = (char *)malloc(new_size);
|
||||||
|
@ -305,7 +305,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
|||||||
char *ptr;
|
char *ptr;
|
||||||
if(conn->trlMax) {
|
if(conn->trlMax) {
|
||||||
conn->trlMax *= 2;
|
conn->trlMax *= 2;
|
||||||
ptr = (char*)realloc(conn->trailer,conn->trlMax);
|
ptr = realloc(conn->trailer,conn->trlMax);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
conn->trlMax=128;
|
conn->trlMax=128;
|
||||||
|
@ -460,7 +460,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* append CRLF to the userpwd header */
|
/* append CRLF to the userpwd header */
|
||||||
tmp = (char*) realloc(*allocuserpwd, strlen(*allocuserpwd) + 3 + 1);
|
tmp = realloc(*allocuserpwd, strlen(*allocuserpwd) + 3 + 1);
|
||||||
if(!tmp)
|
if(!tmp)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
strcat(tmp, "\r\n");
|
strcat(tmp, "\r\n");
|
||||||
|
@ -1079,7 +1079,7 @@ static int alloc_addbyter(int output, FILE *data)
|
|||||||
else if(infop->len+1 >= infop->alloc) {
|
else if(infop->len+1 >= infop->alloc) {
|
||||||
char *newptr;
|
char *newptr;
|
||||||
|
|
||||||
newptr = (char *)realloc(infop->buffer, infop->alloc*2);
|
newptr = realloc(infop->buffer, infop->alloc*2);
|
||||||
|
|
||||||
if(!newptr) {
|
if(!newptr) {
|
||||||
infop->fail = 1;
|
infop->fail = 1;
|
||||||
|
@ -702,7 +702,7 @@ static CURLcode readwrite_headers(struct SessionHandle *data,
|
|||||||
size_t newsize=CURLMAX((k->hbuflen+*nread)*3/2,
|
size_t newsize=CURLMAX((k->hbuflen+*nread)*3/2,
|
||||||
data->state.headersize*2);
|
data->state.headersize*2);
|
||||||
hbufp_index = k->hbufp - data->state.headerbuff;
|
hbufp_index = k->hbufp - data->state.headerbuff;
|
||||||
newbuff = (char *)realloc(data->state.headerbuff, newsize);
|
newbuff = realloc(data->state.headerbuff, newsize);
|
||||||
if(!newbuff) {
|
if(!newbuff) {
|
||||||
failf (data, "Failed to alloc memory for big header!");
|
failf (data, "Failed to alloc memory for big header!");
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
@ -747,7 +747,7 @@ static CURLcode readwrite_headers(struct SessionHandle *data,
|
|||||||
size_t newsize=CURLMAX((k->hbuflen+full_length)*3/2,
|
size_t newsize=CURLMAX((k->hbuflen+full_length)*3/2,
|
||||||
data->state.headersize*2);
|
data->state.headersize*2);
|
||||||
hbufp_index = k->hbufp - data->state.headerbuff;
|
hbufp_index = k->hbufp - data->state.headerbuff;
|
||||||
newbuff = (char *)realloc(data->state.headerbuff, newsize);
|
newbuff = realloc(data->state.headerbuff, newsize);
|
||||||
if(!newbuff) {
|
if(!newbuff) {
|
||||||
failf (data, "Failed to alloc memory for big header!");
|
failf (data, "Failed to alloc memory for big header!");
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
@ -602,8 +602,7 @@ CURLcode Curl_ch_connc(struct SessionHandle *data,
|
|||||||
data->state.lastconnect = -1;
|
data->state.lastconnect = -1;
|
||||||
}
|
}
|
||||||
if(newamount > 0) {
|
if(newamount > 0) {
|
||||||
newptr= (struct connectdata **)
|
newptr = realloc(c->connects, sizeof(struct connectdata *) * newamount);
|
||||||
realloc(c->connects, sizeof(struct connectdata *) * newamount);
|
|
||||||
if(!newptr)
|
if(!newptr)
|
||||||
/* we closed a few connections in vain, but so what? */
|
/* we closed a few connections in vain, but so what? */
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
@ -749,8 +749,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
|
|||||||
|
|
||||||
if (nargs >= lformlen) {
|
if (nargs >= lformlen) {
|
||||||
lformlen += ALLOC_GRANULE;
|
lformlen += ALLOC_GRANULE;
|
||||||
tforms = (struct curl_forms *) realloc((char *) lforms,
|
tforms = realloc(lforms, lformlen * sizeof *lforms);
|
||||||
lformlen * sizeof *lforms);
|
|
||||||
|
|
||||||
if (!tforms) {
|
if (!tforms) {
|
||||||
result = CURL_FORMADD_MEMORY;
|
result = CURL_FORMADD_MEMORY;
|
||||||
|
Loading…
Reference in New Issue
Block a user