From a9b5a9348d51465167c0907a2913f6f14ad28d00 Mon Sep 17 00:00:00 2001 From: cboesch Date: Thu, 25 Nov 2010 10:01:03 +0000 Subject: 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 --- stream/http.c | 7 +++---- stream/network.c | 10 +--------- 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'stream') diff --git a/stream/http.c b/stream/http.c index 91b05c6d1c..9d00f00f87 100644 --- a/stream/http.c +++ b/stream/http.c @@ -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, diff --git a/stream/network.c b/stream/network.c index 1da6f24ca9..c8667686ec 100644 --- a/stream/network.c +++ b/stream/network.c @@ -20,8 +20,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -//#define DUMP2FILE - #include #include #include @@ -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; } -- cgit v1.2.3