comparison stream/http.c @ 30702:9fc9d1e788aa

Do not cast the results of malloc/calloc/realloc. These functions return void*, which is compatible with any pointer, so there is no need for casts.
author diego
date Fri, 26 Feb 2010 15:01:37 +0000
parents 11eebd7c8879
children 304b762b62cb
comparison
equal deleted inserted replaced
30701:3c1f75f4affe 30702:9fc9d1e788aa
330 330
331 if( (unsigned)length > SIZE_MAX - http_hdr->buffer_size - 1) { 331 if( (unsigned)length > SIZE_MAX - http_hdr->buffer_size - 1) {
332 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Bad size in memory (re)allocation\n"); 332 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Bad size in memory (re)allocation\n");
333 return -1; 333 return -1;
334 } 334 }
335 http_hdr->buffer = (char*)realloc( http_hdr->buffer, http_hdr->buffer_size+length+1 ); 335 http_hdr->buffer = realloc( http_hdr->buffer, http_hdr->buffer_size+length+1 );
336 if( http_hdr->buffer==NULL ) { 336 if( http_hdr->buffer==NULL ) {
337 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory (re)allocation failed\n"); 337 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory (re)allocation failed\n");
338 return -1; 338 return -1;
339 } 339 }
340 memcpy( http_hdr->buffer+http_hdr->buffer_size, response, length ); 340 memcpy( http_hdr->buffer+http_hdr->buffer_size, response, length );
426 do { 426 do {
427 ptr = hdr_ptr; 427 ptr = hdr_ptr;
428 while( *ptr!='\r' && *ptr!='\n' ) ptr++; 428 while( *ptr!='\r' && *ptr!='\n' ) ptr++;
429 len = ptr-hdr_ptr; 429 len = ptr-hdr_ptr;
430 if( len==0 ) break; 430 if( len==0 ) break;
431 field = (char*)realloc(field, len+1); 431 field = realloc(field, len+1);
432 if( field==NULL ) { 432 if( field==NULL ) {
433 mp_msg(MSGT_NETWORK,MSGL_ERR,"Memory allocation failed\n"); 433 mp_msg(MSGT_NETWORK,MSGL_ERR,"Memory allocation failed\n");
434 return -1; 434 return -1;
435 } 435 }
436 strncpy( field, hdr_ptr, len ); 436 strncpy( field, hdr_ptr, len );
518 518
519 char * 519 char *
520 http_get_field( HTTP_header_t *http_hdr, const char *field_name ) { 520 http_get_field( HTTP_header_t *http_hdr, const char *field_name ) {
521 if( http_hdr==NULL || field_name==NULL ) return NULL; 521 if( http_hdr==NULL || field_name==NULL ) return NULL;
522 http_hdr->field_search_pos = http_hdr->first_field; 522 http_hdr->field_search_pos = http_hdr->first_field;
523 http_hdr->field_search = (char*)realloc( http_hdr->field_search, strlen(field_name)+1 ); 523 http_hdr->field_search = realloc( http_hdr->field_search, strlen(field_name)+1 );
524 if( http_hdr->field_search==NULL ) { 524 if( http_hdr->field_search==NULL ) {
525 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n"); 525 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
526 return NULL; 526 return NULL;
527 } 527 }
528 strcpy( http_hdr->field_search, field_name ); 528 strcpy( http_hdr->field_search, field_name );