Commit 4c29602d authored by Gildas Bazin's avatar Gildas Bazin

* include/vlc_common.h: free tab if empty in TAB_REMOVE().

* src/misc/httpd.c: fixed a few memory leaks and coding style changes.
* modules/access_output/http.c: a few coding style changes.
parent 59e170a6
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.111 2004/03/03 13:25:00 fenrir Exp $ * $Id$
* *
* Authors: Samuel Hocevar <sam@via.ecp.fr> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -506,12 +506,12 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */ ...@@ -506,12 +506,12 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */
((void**)(tab) + _i_index_+1), \ ((void**)(tab) + _i_index_+1), \
( (count) - _i_index_ - 1 ) * sizeof( void* ) );\ ( (count) - _i_index_ - 1 ) * sizeof( void* ) );\
} \ } \
else \ (count)--; \
if( (count) == 0 ) \
{ \ { \
free( tab ); \ free( tab ); \
(tab) = NULL; \ (tab) = NULL; \
} \ } \
(count)--; \
} \ } \
} }
......
...@@ -197,10 +197,12 @@ static int Open( vlc_object_t *p_this ) ...@@ -197,10 +197,12 @@ static int Open( vlc_object_t *p_this )
psz_file_name = strdup( psz_file_name ); psz_file_name = strdup( psz_file_name );
} }
p_sys->p_httpd_host = httpd_HostNew( VLC_OBJECT(p_access), psz_bind_addr, i_bind_port ); p_sys->p_httpd_host = httpd_HostNew( VLC_OBJECT(p_access), psz_bind_addr,
i_bind_port );
if( p_sys->p_httpd_host == NULL ) if( p_sys->p_httpd_host == NULL )
{ {
msg_Err( p_access, "cannot listen on %s:%d", psz_bind_addr, i_bind_port ); msg_Err( p_access, "cannot listen on %s:%d",
psz_bind_addr, i_bind_port );
free( psz_name ); free( psz_name );
free( psz_file_name ); free( psz_file_name );
...@@ -213,8 +215,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -213,8 +215,8 @@ static int Open( vlc_object_t *p_this )
psz_mime = "video/x-ms-asf-stream"; psz_mime = "video/x-ms-asf-stream";
} }
p_sys->p_httpd_stream = httpd_StreamNew( p_sys->p_httpd_host, p_sys->p_httpd_stream =
psz_file_name, psz_mime, httpd_StreamNew( p_sys->p_httpd_host, psz_file_name, psz_mime,
sout_cfg_find_value( p_access->p_cfg, "user" ), sout_cfg_find_value( p_access->p_cfg, "user" ),
sout_cfg_find_value( p_access->p_cfg, "pwd" ) ); sout_cfg_find_value( p_access->p_cfg, "pwd" ) );
if( p_sys->p_httpd_stream == NULL ) if( p_sys->p_httpd_stream == NULL )
...@@ -288,10 +290,13 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) ...@@ -288,10 +290,13 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
p_sys->i_header_size = 0; p_sys->i_header_size = 0;
p_sys->b_header_complete = VLC_FALSE; p_sys->b_header_complete = VLC_FALSE;
} }
if( (int)(p_buffer->i_size + p_sys->i_header_size) > p_sys->i_header_allocated ) if( (int)(p_buffer->i_size + p_sys->i_header_size) >
p_sys->i_header_allocated )
{ {
p_sys->i_header_allocated = p_buffer->i_size + p_sys->i_header_size + 1024; p_sys->i_header_allocated =
p_sys->p_header = realloc( p_sys->p_header, p_sys->i_header_allocated ); p_buffer->i_size + p_sys->i_header_size + 1024;
p_sys->p_header =
realloc( p_sys->p_header, p_sys->i_header_allocated );
} }
memcpy( &p_sys->p_header[p_sys->i_header_size], memcpy( &p_sys->p_header[p_sys->i_header_size],
p_buffer->p_buffer, p_buffer->p_buffer,
...@@ -302,11 +307,13 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) ...@@ -302,11 +307,13 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
{ {
p_sys->b_header_complete = VLC_TRUE; p_sys->b_header_complete = VLC_TRUE;
httpd_StreamHeader( p_sys->p_httpd_stream, p_sys->p_header, p_sys->i_header_size ); httpd_StreamHeader( p_sys->p_httpd_stream, p_sys->p_header,
p_sys->i_header_size );
} }
/* send data */ /* send data */
i_err = httpd_StreamSend( p_sys->p_httpd_stream, p_buffer->p_buffer, p_buffer->i_size ); i_err = httpd_StreamSend( p_sys->p_httpd_stream, p_buffer->p_buffer,
p_buffer->i_size );
p_next = p_buffer->p_next; p_next = p_buffer->p_next;
sout_BufferDelete( p_access->p_sout, p_buffer ); sout_BufferDelete( p_access->p_sout, p_buffer );
...@@ -340,4 +347,3 @@ static int Seek( sout_access_out_t *p_access, off_t i_pos ) ...@@ -340,4 +347,3 @@ static int Seek( sout_access_out_t *p_access, off_t i_pos )
msg_Warn( p_access, "HTTP sout access cannot seek" ); msg_Warn( p_access, "HTTP sout access cannot seek" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment