1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-21 22:30:22 +00:00

stream/network.c, stream/http.c: cleanup

Simplify mime_type_table loop

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32644 b3059339-0415-0410-9bf9-f77b7e298cf2

Remove dead define

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32645 b3059339-0415-0410-9bf9-f77b7e298cf2

Remove GCC warning hack not needed anymore

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32646 b3059339-0415-0410-9bf9-f77b7e298cf2

Use calloc instead of malloc+memset.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32647 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
cboesch 2010-11-25 10:01:03 +00:00 committed by Uoti Urpala
parent 9bf59a1fcb
commit a9b5a9348d
2 changed files with 4 additions and 13 deletions

View File

@ -764,7 +764,6 @@ static void print_icy_metadata(HTTP_header_t *http_hdr) {
//! If this function succeeds you must closesocket stream->fd
static int http_streaming_start(stream_t *stream, int* file_format) {
HTTP_header_t *http_hdr = NULL;
unsigned int i;
int fd = stream->fd;
int res = STREAM_UNSUPPORTED;
int redirect = 0;
@ -853,16 +852,16 @@ static int http_streaming_start(stream_t *stream, int* file_format) {
// Look if we can use the Content-Type
content_type = http_get_field( http_hdr, "Content-Type" );
if( content_type!=NULL ) {
unsigned int i;
mp_msg(MSGT_NETWORK,MSGL_V,"Content-Type: [%s]\n", content_type );
// Check in the mime type table for a demuxer type
i = 0;
while(mime_type_table[i].mime_type != NULL) {
for (i = 0; mime_type_table[i].mime_type != NULL; i++) {
if( !strcasecmp( content_type, mime_type_table[i].mime_type ) ) {
*file_format = mime_type_table[i].demuxer_type;
res = seekable;
goto out;
}
i++;
}
}
// Not found in the mime type table, don't fail,

View File

@ -20,8 +20,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//#define DUMP2FILE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -114,13 +112,11 @@ const mime_struct_t mime_type_table[] = {
streaming_ctrl_t *
streaming_ctrl_new(void) {
streaming_ctrl_t *streaming_ctrl;
streaming_ctrl = malloc(sizeof(streaming_ctrl_t));
streaming_ctrl_t *streaming_ctrl = calloc(1, sizeof(*streaming_ctrl));
if( streaming_ctrl==NULL ) {
mp_tmsg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed.\n");
return NULL;
}
memset( streaming_ctrl, 0, sizeof(streaming_ctrl_t) );
return streaming_ctrl;
}
@ -475,10 +471,6 @@ nop_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctr
int
nop_streaming_seek( int fd, off_t pos, streaming_ctrl_t *stream_ctrl ) {
return -1;
// To shut up gcc warning
fd++;
pos++;
stream_ctrl=NULL;
}