From 25232e200b39db62c3e49f9269c215a71873c7f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sun, 6 Dec 2009 10:54:28 +0200 Subject: [PATCH] Do not assert memory allocations --- modules/access/dshow/dshow.cpp | 13 ++--- modules/access/dvb/en50221.c | 38 +++++--------- modules/access/jack.c | 3 +- modules/access/mms/buffer.c | 12 ++--- modules/access/mms/mmsh.c | 6 +-- modules/access/mms/mmstu.c | 16 ++---- modules/access_output/http.c | 15 ++---- modules/audio_filter/converter/dtstospdif.c | 7 +-- modules/audio_output/alsa.c | 8 +-- modules/audio_output/waveout.c | 9 +--- modules/codec/cmml/xurl.c | 9 +--- modules/codec/dvbsub.c | 18 ++----- modules/codec/flac.c | 12 ++--- modules/codec/kate.c | 9 +--- modules/codec/quicktime.c | 6 +-- modules/codec/realvideo.c | 6 +-- modules/codec/speex.c | 18 ++----- modules/codec/subtitles/subsdec.c | 6 +-- modules/codec/theora.c | 12 ++--- modules/codec/vorbis.c | 12 ++--- modules/control/http/macro.c | 23 +++------ modules/control/http/mvar.c | 15 ++---- modules/control/http/util.c | 15 ++---- modules/control/rc.c | 7 +-- modules/control/telnet.c | 15 ++---- modules/demux/asademux.c | 18 +++---- modules/demux/gme.cpp | 21 ++++---- modules/demux/live555.cpp | 25 +++------ modules/demux/mkv/chapters.cpp | 6 +-- modules/demux/mkv/matroska_segment.cpp | 57 +++++++-------------- modules/demux/nuv.c | 6 +-- modules/demux/playlist/asx.c | 21 +++----- modules/demux/subtitle.c | 16 ++---- modules/demux/ts.c | 16 ++---- modules/demux/vobsub.c | 23 ++++----- modules/misc/freetype.c | 6 +-- modules/misc/xml/xtag.c | 23 +++------ modules/mux/avi.c | 6 +-- modules/mux/mp4.c | 12 ++--- modules/mux/ogg.c | 6 +-- modules/packetizer/mpeg4video.c | 9 +--- modules/packetizer/vc1.c | 9 ++-- modules/services_discovery/sap.c | 3 +- modules/stream_out/bridge.c | 18 +++---- modules/stream_out/mosaic_bridge.c | 13 ++--- modules/video_filter/audiobargraph_v.c | 6 +-- modules/video_filter/bluescreen.c | 8 +-- modules/video_filter/gaussianblur.c | 9 +--- modules/video_filter/mosaic.c | 15 ++---- modules/video_filter/rss.c | 7 +-- modules/video_output/msw/directx.c | 9 +--- 51 files changed, 193 insertions(+), 485 deletions(-) diff --git a/modules/access/dshow/dshow.cpp b/modules/access/dshow/dshow.cpp index 710280c5dd..c5e86362c1 100644 --- a/modules/access/dshow/dshow.cpp +++ b/modules/access/dshow/dshow.cpp @@ -34,8 +34,6 @@ #define __STDC_FORMAT_MACROS 1 #include -#include - #include #include #include @@ -43,7 +41,6 @@ #include #include #include -#include #include "common.h" #include "filter.h" @@ -1104,10 +1101,8 @@ static int OpenDevice( vlc_object_t *p_this, access_sys_t *p_sys, dshow_stream.p_device_filter = p_device_filter; dshow_stream.p_capture_filter = p_capture_filter; - p_sys->pp_streams = (dshow_stream_t **)realloc_or_free( - p_sys->pp_streams, + p_sys->pp_streams = (dshow_stream_t **)xrealloc( p_sys->pp_streams, sizeof(dshow_stream_t *) * (p_sys->i_streams + 1) ); - assert( p_sys->pp_streams ); p_sys->pp_streams[p_sys->i_streams] = new dshow_stream_t; *p_sys->pp_streams[p_sys->i_streams++] = dshow_stream; @@ -1968,12 +1963,10 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name, if( !list_devices.size() ) return VLC_SUCCESS; - p_item->ppsz_list = (char**)realloc_or_free( p_item->ppsz_list, + p_item->ppsz_list = (char**)xrealloc( p_item->ppsz_list, (list_devices.size()+3) * sizeof(char *) ); - assert( p_item->ppsz_list ); - p_item->ppsz_list_text = (char**)realloc_or_free( p_item->ppsz_list_text, + p_item->ppsz_list_text = (char**)xrealloc( p_item->ppsz_list_text, (list_devices.size()+3) * sizeof(char *) ); - assert( p_item->ppsz_list_text ); list::iterator iter; for( iter = list_devices.begin(), i = 2; iter != list_devices.end(); diff --git a/modules/access/dvb/en50221.c b/modules/access/dvb/en50221.c index d17a24aa84..1ad3c0e801 100644 --- a/modules/access/dvb/en50221.c +++ b/modules/access/dvb/en50221.c @@ -272,8 +272,7 @@ static int TPDURecv( access_t * p_access, uint8_t i_slot, uint8_t *pi_tag, if ( pi_size == NULL ) { - p_data = malloc( MAX_TPDU_SIZE ); - assert( p_data ); + p_data = xmalloc( MAX_TPDU_SIZE ); } for ( ; ; ) @@ -354,13 +353,11 @@ static int SPDUSend( access_t * p_access, int i_session_id, uint8_t *p_data, int i_size ) { access_sys_t *p_sys = p_access->p_sys; - uint8_t *p_spdu = malloc( i_size + 4 ); + uint8_t *p_spdu = xmalloc( i_size + 4 ); uint8_t *p = p_spdu; uint8_t i_tag; uint8_t i_slot = p_sys->p_sessions[i_session_id - 1].i_slot; - assert( p_spdu ); - *p++ = ST_SESSION_NUMBER; *p++ = 0x02; *p++ = (i_session_id >> 8); @@ -804,13 +801,11 @@ static int APDUSend( access_t * p_access, int i_session_id, int i_tag, uint8_t *p_data, int i_size ) { access_sys_t *p_sys = p_access->p_sys; - uint8_t *p_apdu = malloc( i_size + 12 ); + uint8_t *p_apdu = xmalloc( i_size + 12 ); uint8_t *p = p_apdu; ca_msg_t ca_msg; int i_ret; - assert( p_apdu ); - *p++ = (i_tag >> 16); *p++ = (i_tag >> 8) & 0xff; *p++ = i_tag & 0xff; @@ -1052,11 +1047,9 @@ static uint8_t *CAPMTHeader( system_ids_t *p_ids, uint8_t i_list_mgt, uint8_t *p_data; if ( i_size ) - p_data = malloc( 7 + i_size ); + p_data = xmalloc( 7 + i_size ); else - p_data = malloc( 6 ); - - assert( p_data ); + p_data = xmalloc( 6 ); p_data[0] = i_list_mgt; p_data[1] = i_program_number >> 8; @@ -1108,11 +1101,9 @@ static uint8_t *CAPMTES( system_ids_t *p_ids, uint8_t *p_capmt, int i; if ( i_size ) - p_data = realloc( p_capmt, i_capmt_size + 6 + i_size ); + p_data = xrealloc( p_capmt, i_capmt_size + 6 + i_size ); else - p_data = realloc( p_capmt, i_capmt_size + 5 ); - - assert( p_data ); + p_data = xrealloc( p_capmt, i_capmt_size + 5 ); i = i_capmt_size; @@ -1581,8 +1572,7 @@ static void MMISendObject( access_t *p_access, int i_session_id, case EN50221_MMI_ANSW: i_tag = AOT_ANSW; i_size = 1 + strlen( p_object->u.answ.psz_answ ); - p_data = malloc( i_size ); - assert( p_data ); + p_data = xmalloc( i_size ); p_data[0] = (p_object->u.answ.b_ok == true) ? 0x1 : 0x0; strncpy( (char *)&p_data[1], p_object->u.answ.psz_answ, i_size - 1 ); break; @@ -1590,8 +1580,7 @@ static void MMISendObject( access_t *p_access, int i_session_id, case EN50221_MMI_MENU_ANSW: i_tag = AOT_MENU_ANSW; i_size = 1; - p_data = malloc( i_size ); - assert( p_data ); + p_data = xmalloc( i_size ); p_data[0] = p_object->u.menu_answ.i_choice; break; @@ -1677,8 +1666,7 @@ static void MMIHandleEnq( access_t *p_access, int i_session_id, p_mmi->last_object.u.enq.b_blind = (*d & 0x1) ? true : false; d += 2; /* skip answer_text_length because it is not mandatory */ l -= 2; - p_mmi->last_object.u.enq.psz_text = malloc( l + 1 ); - assert( p_mmi->last_object.u.enq.psz_text ); + p_mmi->last_object.u.enq.psz_text = xmalloc( l + 1 ); strncpy( p_mmi->last_object.u.enq.psz_text, (char *)d, l ); p_mmi->last_object.u.enq.psz_text[l] = '\0'; @@ -1820,9 +1808,8 @@ static void MMIOpen( access_t *p_access, int i_session_id ) p_sys->p_sessions[i_session_id - 1].pf_handle = MMIHandle; p_sys->p_sessions[i_session_id - 1].pf_close = MMIClose; - p_sys->p_sessions[i_session_id - 1].p_sys = malloc(sizeof(mmi_t)); + p_sys->p_sessions[i_session_id - 1].p_sys = xmalloc(sizeof(mmi_t)); p_mmi = (mmi_t *)p_sys->p_sessions[i_session_id - 1].p_sys; - assert( p_mmi ); p_mmi->last_object.i_object_type = EN50221_MMI_NONE; } @@ -2452,8 +2439,7 @@ char *dvbsi_to_utf8( const char *psz_instring, size_t i_length ) iconv_handle = vlc_iconv_open( "UTF-8", psz_encoding ); i_in = i_length - (psz_stringstart - psz_instring ); i_out = i_in * 6; - psz_outstring = psz_tmp = (char*)malloc( i_out + 1 ); - assert( psz_outstring ); + psz_outstring = psz_tmp = (char*)xmalloc( i_out + 1 ); vlc_iconv( iconv_handle, &psz_stringstart, &i_in, &psz_tmp, &i_out ); vlc_iconv_close( iconv_handle ); *psz_tmp = '\0'; diff --git a/modules/access/jack.c b/modules/access/jack.c index fbbac2d08d..217b6e4aa0 100644 --- a/modules/access/jack.c +++ b/modules/access/jack.c @@ -541,9 +541,8 @@ static void Port_finder( demux_t *p_demux ) i_out_ports++; } /* alloc an array to store all the matched ports */ - p_sys->pp_jack_port_table = realloc( p_sys->pp_jack_port_table, + p_sys->pp_jack_port_table = xrealloc( p_sys->pp_jack_port_table, (i_out_ports * sizeof( char * ) + i_total_out_ports * sizeof( char * ) ) ); - assert( p_sys->pp_jack_port_table ); for(int i=0; i - #include -#include #include "asf.h" #include "buffer.h" @@ -71,8 +68,7 @@ void var_buffer_add8 ( var_buffer_t *p_buf, uint8_t i_byte ) if( p_buf->i_data >= p_buf->i_size ) { p_buf->i_size += 1024; - p_buf->p_data = realloc_or_free( p_buf->p_data, p_buf->i_size ); - assert( p_buf->p_data ); + p_buf->p_data = xrealloc( p_buf->p_data, p_buf->i_size ); } p_buf->p_data[p_buf->i_data] = i_byte&0xff; p_buf->i_data++; @@ -102,8 +98,7 @@ void var_buffer_addmemory( var_buffer_t *p_buf, void *p_mem, int i_mem ) if( p_buf->i_data + i_mem >= p_buf->i_size ) { p_buf->i_size += i_mem + 1024; - p_buf->p_data = realloc_or_free( p_buf->p_data, p_buf->i_size ); - assert( p_buf->p_data ); + p_buf->p_data = xrealloc( p_buf->p_data, p_buf->i_size ); } memcpy( p_buf->p_data + p_buf->i_data, p_mem, i_mem ); @@ -124,8 +119,7 @@ void var_buffer_addUTF16( var_buffer_t *p_buf, const char *p_str ) size_t i_out = i_in * 4; char *psz_out, *psz_tmp; - psz_out = psz_tmp = malloc( i_out + 1 ); - assert( psz_out ); + psz_out = psz_tmp = xmalloc( i_out + 1 ); iconv_handle = vlc_iconv_open( "UTF-16LE", "UTF-8" ); vlc_iconv( iconv_handle, &p_str, &i_in, &psz_tmp, &i_out ); vlc_iconv_close( iconv_handle ); diff --git a/modules/access/mms/mmsh.c b/modules/access/mms/mmsh.c index 98784b21b9..2c2d21083c 100644 --- a/modules/access/mms/mmsh.c +++ b/modules/access/mms/mmsh.c @@ -29,13 +29,10 @@ # include "config.h" #endif -#include - #include #include #include #include -#include #include #include @@ -737,8 +734,7 @@ static void GetHeader( access_t *p_access ) if( ck.i_data > 0 ) { p_sys->i_header += ck.i_data; - p_sys->p_header = realloc_or_free( p_sys->p_header, p_sys->i_header ); - assert( p_sys->p_header ); + p_sys->p_header = xrealloc( p_sys->p_header, p_sys->i_header ); memcpy( &p_sys->p_header[p_sys->i_header - ck.i_data], ck.p_data, ck.i_data ); } diff --git a/modules/access/mms/mmstu.c b/modules/access/mms/mmstu.c index cf2ac5e112..ebbf2239eb 100644 --- a/modules/access/mms/mmstu.c +++ b/modules/access/mms/mmstu.c @@ -31,7 +31,6 @@ #include #include -#include #include #include @@ -604,8 +603,7 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto ) #define GETUTF16( psz, size ) \ { \ int i; \ - psz = malloc( size + 1); \ - assert( psz ); \ + psz = xmalloc( size + 1); \ for( i = 0; i < size; i++ ) \ { \ psz[i] = p[i]; \ @@ -1187,8 +1185,7 @@ static int mms_ParseCommand( access_t *p_access, free( p_sys->p_cmd ); p_sys->i_cmd = i_data; - p_sys->p_cmd = malloc( i_data ); - assert( p_sys->p_cmd ); + p_sys->p_cmd = xmalloc( i_data ); memcpy( p_sys->p_cmd, p_data, i_data ); *pi_used = i_data; /* by default */ @@ -1311,9 +1308,8 @@ static int mms_ParsePacket( access_t *p_access, { if( p_sys->p_header ) { - p_sys->p_header = realloc_or_free( p_sys->p_header, + p_sys->p_header = xrealloc( p_sys->p_header, p_sys->i_header + i_packet_length - 8 ); - assert( p_sys->p_header ); memcpy( &p_sys->p_header[p_sys->i_header], p_data + 8, i_packet_length - 8 ); p_sys->i_header += i_packet_length - 8; @@ -1321,8 +1317,7 @@ static int mms_ParsePacket( access_t *p_access, } else { - uint8_t* p_packet = malloc( i_packet_length - 8 ); // don't bother with preheader - assert( p_packet ); + uint8_t* p_packet = xmalloc( i_packet_length - 8 ); // don't bother with preheader memcpy( p_packet, p_data + 8, i_packet_length - 8 ); p_sys->p_header = p_packet; p_sys->i_header = i_packet_length - 8; @@ -1335,8 +1330,7 @@ static int mms_ParsePacket( access_t *p_access, } else { - uint8_t* p_packet = malloc( i_packet_length - 8 ); // don't bother with preheader - assert( p_packet ); + uint8_t* p_packet = xmalloc( i_packet_length - 8 ); // don't bother with preheader memcpy( p_packet, p_data + 8, i_packet_length - 8 ); FREENULL( p_sys->p_media ); p_sys->p_media = p_packet; diff --git a/modules/access_output/http.c b/modules/access_output/http.c index b45ffe0674..fe2fe8b5c7 100644 --- a/modules/access_output/http.c +++ b/modules/access_output/http.c @@ -30,15 +30,14 @@ # include "config.h" #endif -#include - #include #include #include #include + + #include #include -#include #if 0 //def HAVE_AVAHI_CLIENT #include "bonjour.h" @@ -318,18 +317,13 @@ static int Open( vlc_object_t *p_this ) p_sys->i_header_allocated = 1024; p_sys->i_header_size = 0; - p_sys->p_header = malloc( p_sys->i_header_allocated ); + p_sys->p_header = xmalloc( p_sys->i_header_allocated ); p_sys->b_header_complete = false; - if( !p_sys->p_header ) - p_sys->i_header_allocated = 0; p_access->pf_write = Write; p_access->pf_seek = Seek; p_access->pf_control = Control; - /* XXX Do we deal gracefully with p_sys->p_header == NULL? */ - assert( p_sys->p_header ); - return VLC_SUCCESS; } @@ -399,9 +393,8 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer ) { p_sys->i_header_allocated = p_buffer->i_buffer + p_sys->i_header_size + 1024; - p_sys->p_header = realloc_or_free( p_sys->p_header, + p_sys->p_header = xrealloc( p_sys->p_header, p_sys->i_header_allocated ); - assert( p_sys->p_header ); } memcpy( &p_sys->p_header[p_sys->i_header_size], p_buffer->p_buffer, diff --git a/modules/audio_filter/converter/dtstospdif.c b/modules/audio_filter/converter/dtstospdif.c index 49a61e82e1..c345e011cd 100644 --- a/modules/audio_filter/converter/dtstospdif.c +++ b/modules/audio_filter/converter/dtstospdif.c @@ -28,16 +28,12 @@ # include "config.h" #endif -#include - #include #include #include #include -#include - /***************************************************************************** * Local structures *****************************************************************************/ @@ -129,9 +125,8 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf ) p_filter->p_sys->i_frame_size, p_in_buf->i_buffer ); p_filter->p_sys->i_frame_size = p_in_buf->i_buffer; - p_filter->p_sys->p_buf = realloc_or_free( p_filter->p_sys->p_buf, + p_filter->p_sys->p_buf = xrealloc( p_filter->p_sys->p_buf, p_in_buf->i_buffer * 3 ); - assert( p_filter->p_sys->p_buf ); p_filter->p_sys->i_frames = 0; } diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c index 84e3fd5e7f..36b8c9a990 100644 --- a/modules/audio_output/alsa.c +++ b/modules/audio_output/alsa.c @@ -42,8 +42,6 @@ #include #include -#include - /* ALSA part Note: we use the new API which is available since 0.9.0beta10a. */ #define ALSA_PCM_NEW_HW_PARAMS_API @@ -1004,12 +1002,10 @@ static void GetDevicesForCard( module_config_t *p_item, int i_card ) break; } - p_item->ppsz_list = realloc_or_free( p_item->ppsz_list, + p_item->ppsz_list = xrealloc( p_item->ppsz_list, (p_item->i_list + 2) * sizeof(char *) ); - assert( p_item->ppsz_list ); - p_item->ppsz_list_text = realloc_or_free( p_item->ppsz_list_text, + p_item->ppsz_list_text = xrealloc( p_item->ppsz_list_text, (p_item->i_list + 2) * sizeof(char *) ); - assert( p_item->ppsz_list_text ); p_item->ppsz_list[ p_item->i_list ] = psz_device; p_item->ppsz_list_text[ p_item->i_list ] = psz_descr; p_item->i_list++; diff --git a/modules/audio_output/waveout.c b/modules/audio_output/waveout.c index 71497d6368..6325b53caf 100644 --- a/modules/audio_output/waveout.c +++ b/modules/audio_output/waveout.c @@ -30,13 +30,10 @@ # include "config.h" #endif -#include - #include #include #include #include -#include #include #include @@ -1174,12 +1171,10 @@ static int ReloadWaveoutDevices( vlc_object_t *p_this, char const *psz_name, int wave_devices = waveOutGetNumDevs(); - p_item->ppsz_list = realloc_or_free( p_item->ppsz_list, + p_item->ppsz_list = xrealloc( p_item->ppsz_list, (wave_devices+2) * sizeof(char *) ); - assert( p_item->ppsz_list ); - p_item->ppsz_list_text = realloc_or_free( p_item->ppsz_list_text, + p_item->ppsz_list_text = xrealloc( p_item->ppsz_list_text, (wave_devices+2) * sizeof(char *) ); - assert( p_item->ppsz_list_text ); WAVEOUTCAPS caps; char sz_dev_name[MAXPNAMELEN+32]; diff --git a/modules/codec/cmml/xurl.c b/modules/codec/cmml/xurl.c index 1f40e0e3c6..491fb29de4 100644 --- a/modules/codec/cmml/xurl.c +++ b/modules/codec/cmml/xurl.c @@ -28,9 +28,6 @@ #endif #include -#include - -#include #include "xurl.h" @@ -385,8 +382,7 @@ char *XURL_GetHead( const char *psz_path ) size_t i_characters_until_last_slash; i_characters_until_last_slash = pc_last_slash - psz_path; - psz_path_head = malloc( i_characters_until_last_slash + 1 ); - assert( psz_path_head ); + psz_path_head = xmalloc( i_characters_until_last_slash + 1 ); strncpy( psz_path_head, psz_path, i_characters_until_last_slash + 1 ); /* terminate the resulting string with '\0' */ @@ -439,8 +435,7 @@ static char *streallocat( char *psz_string, const char *psz_to_append ) size_t i_new_string_length = strlen( psz_string ) + strlen( psz_to_append ) + 1; - psz_string = realloc_or_free( psz_string, i_new_string_length ); - assert( psz_string ); + psz_string = xrealloc( psz_string, i_new_string_length ); return strcat( psz_string, psz_to_append ); } diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c index 4fecfc3d88..5ad83982a1 100644 --- a/modules/codec/dvbsub.c +++ b/modules/codec/dvbsub.c @@ -71,13 +71,10 @@ # include "config.h" #endif -#include - #include #include #include #include -#include #include @@ -916,8 +913,7 @@ static void decode_region_composition( decoder_t *p_dec, bs_t *s ) free( p_region->p_pixbuf ); } - p_region->p_pixbuf = malloc( i_height * i_width ); - assert( p_region->p_pixbuf ); + p_region->p_pixbuf = xmalloc( i_height * i_width ); p_region->i_depth = 0; b_fill = true; } @@ -951,9 +947,8 @@ static void decode_region_composition( decoder_t *p_dec, bs_t *s ) /* We create a new object */ p_region->i_object_defs++; - p_region->p_object_defs = realloc_or_free( p_region->p_object_defs, + p_region->p_object_defs = xrealloc( p_region->p_object_defs, sizeof(dvbsub_objectdef_t) * p_region->i_object_defs ); - assert( p_region->p_object_defs ); /* We parse object properties */ p_obj = &p_region->p_object_defs[p_region->i_object_defs - 1]; @@ -1169,9 +1164,8 @@ static void decode_object( decoder_t *p_dec, bs_t *s ) if( p_region->p_object_defs[i].i_id != i_id ) continue; p_region->p_object_defs[i].psz_text = - realloc_or_free( p_region->p_object_defs[i].psz_text, + xrealloc( p_region->p_object_defs[i].psz_text, i_number_of_codes + 1 ); - assert( p_region->p_object_defs[i].psz_text ); /* FIXME 16bits -> char ??? See Preamble */ for( j = 0; j < i_number_of_codes; j++ ) @@ -1843,9 +1837,8 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic ) #endif #ifndef RANDOM_DITHERING - pi_delta = malloc( ( p_region->p_picture->p[0].i_pitch + 1 ) + pi_delta = xmalloc( ( p_region->p_picture->p[0].i_pitch + 1 ) * sizeof(int) * 4 ); - assert( pi_delta ); for( i = 0; i < (p_region->p_picture->p[0].i_pitch + 1) * 4 ; i++ ) { pi_delta[ i ] = 0; @@ -2084,9 +2077,8 @@ static void encode_page_composition( encoder_t *p_enc, bs_t *s, { encoder_region_t region; region.i_width = region.i_height = 0; - p_sys->p_regions = realloc_or_free( p_sys->p_regions, + p_sys->p_regions = xrealloc( p_sys->p_regions, sizeof(encoder_region_t) * (p_sys->i_regions + 1) ); - assert( p_sys->p_regions ); p_sys->p_regions[p_sys->i_regions++] = region; } diff --git a/modules/codec/flac.c b/modules/codec/flac.c index 449ecf60ea..1c3e0e369a 100644 --- a/modules/codec/flac.c +++ b/modules/codec/flac.c @@ -30,13 +30,10 @@ # include "config.h" #endif -#include - #include #include #include #include -#include #ifdef HAVE_FLAC_STREAM_DECODER_H # include @@ -365,9 +362,8 @@ static void ProcessHeader( decoder_t *p_dec ) if( p_dec->fmt_out.i_codec == VLC_CODEC_FLAC ) { p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra; - p_dec->fmt_out.p_extra = realloc_or_free( p_dec->fmt_out.p_extra, + p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra ); - /*assert( p_dec->fmt_out.p_extra ); assert undefined here? */ memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra ); } @@ -1372,8 +1368,7 @@ static block_t *Encode( encoder_t *p_enc, aout_buffer_t *p_aout_buf ) if( p_sys->i_buffer < p_aout_buf->i_buffer * 2 ) { p_sys->p_buffer = - realloc_or_free( p_sys->p_buffer, p_aout_buf->i_buffer * 2 ); - assert( p_sys->p_buffer ); + xrealloc( p_sys->p_buffer, p_aout_buf->i_buffer * 2 ); p_sys->i_buffer = p_aout_buf->i_buffer * 2; } @@ -1441,8 +1436,7 @@ EncoderWriteCallback( const FLAC__StreamEncoder *encoder, /* Backup the STREAMINFO metadata block */ p_enc->fmt_out.i_extra = STREAMINFO_SIZE + 4; - p_enc->fmt_out.p_extra = malloc( STREAMINFO_SIZE + 4 ); - assert( p_enc->fmt_out.p_extra ); + p_enc->fmt_out.p_extra = xmalloc( STREAMINFO_SIZE + 4 ); memcpy( p_enc->fmt_out.p_extra, "fLaC", 4 ); memcpy( ((uint8_t *)p_enc->fmt_out.p_extra) + 4, buffer, STREAMINFO_SIZE ); diff --git a/modules/codec/kate.c b/modules/codec/kate.c index d2bf064e9f..c06c5cd6df 100644 --- a/modules/codec/kate.c +++ b/modules/codec/kate.c @@ -28,14 +28,11 @@ # include "config.h" #endif -#include - #include #include #include #include #include -#include #include #ifdef HAVE_TIGER @@ -506,9 +503,8 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) /* Backup headers as extra data */ uint8_t *p_extra; - p_dec->fmt_in.p_extra = realloc_or_free( p_dec->fmt_in.p_extra, + p_dec->fmt_in.p_extra = xrealloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra + kp.nbytes + 2 ); - assert( p_dec->fmt_in.p_extra ); p_extra = (void*)(((unsigned char*)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra); *(p_extra++) = kp.nbytes >> 8; *(p_extra++) = kp.nbytes & 0xFF; @@ -628,9 +624,8 @@ static int ProcessHeaders( decoder_t *p_dec ) else { p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra; - p_dec->fmt_out.p_extra = realloc_or_free( p_dec->fmt_out.p_extra, + p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra ); - assert( p_dec->fmt_out.p_extra ); memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra ); } diff --git a/modules/codec/quicktime.c b/modules/codec/quicktime.c index 106e5a6260..0bdb005c20 100644 --- a/modules/codec/quicktime.c +++ b/modules/codec/quicktime.c @@ -30,13 +30,10 @@ # include "config.h" #endif -#include - #include #include #include #include -#include #if !defined (__APPLE__) && !defined(WIN32) # define LOADER 1 @@ -585,8 +582,7 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block ) if( p_sys->i_buffer_size < p_sys->i_buffer + p_block->i_buffer ) { p_sys->i_buffer_size = p_sys->i_buffer + p_block->i_buffer + 1024; - p_sys->p_buffer = realloc_or_free( p_sys->p_buffer, p_sys->i_buffer_size ); - assert( p_sys->p_buffer ); + p_sys->p_buffer = xrealloc( p_sys->p_buffer, p_sys->i_buffer_size ); } memcpy( &p_sys->p_buffer[p_sys->i_buffer], p_block->p_buffer, p_block->i_buffer ); diff --git a/modules/codec/realvideo.c b/modules/codec/realvideo.c index 8c00e9bd98..5b2c5a46c4 100644 --- a/modules/codec/realvideo.c +++ b/modules/codec/realvideo.c @@ -26,8 +26,6 @@ # include "config.h" #endif -#include - #include #include #include @@ -216,7 +214,9 @@ static int InitVideo(decoder_t *p_dec) int i_vide = p_dec->fmt_in.i_extra; unsigned int *p_vide = p_dec->fmt_in.p_extra; decoder_sys_t *p_sys = calloc( 1, sizeof( decoder_sys_t ) ); - assert( p_sys ); + + if( !p_sys ) + return VLC_ENOMEM; if( i_vide < 8 ) { diff --git a/modules/codec/speex.c b/modules/codec/speex.c index d7ec977c19..f331c82be8 100644 --- a/modules/codec/speex.c +++ b/modules/codec/speex.c @@ -28,14 +28,11 @@ # include "config.h" #endif -#include - #include #include #include #include #include -#include #include #include @@ -309,9 +306,8 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) { uint8_t *p_extra; - p_dec->fmt_in.p_extra = realloc_or_free( p_dec->fmt_in.p_extra, + p_dec->fmt_in.p_extra = xrealloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra + oggpacket.bytes + 2 ); - assert( p_dec->fmt_in.p_extra ); p_extra = ((uint8_t *)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra; *(p_extra++) = oggpacket.bytes >> 8; *(p_extra++) = oggpacket.bytes & 0xFF; @@ -395,9 +391,8 @@ static int ProcessHeaders( decoder_t *p_dec ) if( p_sys->b_packetizer ) { p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra; - p_dec->fmt_out.p_extra = realloc_or_free( p_dec->fmt_out.p_extra, + p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra ); - assert( p_dec->fmt_out.p_extra ); memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra ); } @@ -533,8 +528,7 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket, block_t *p_new_block = NULL; i_pcm_output_size = p_sys->p_header->frame_size; - p_frame_holder = (short*)malloc( sizeof(short)*i_pcm_output_size ); - assert( p_frame_holder ); + p_frame_holder = (short*)xmalloc( sizeof(short)*i_pcm_output_size ); speex_bits_read_from( &p_sys->bits, (char*)p_oggpacket->packet, p_oggpacket->bytes); @@ -1005,8 +999,7 @@ static int OpenEncoder( vlc_object_t *p_this ) p_sys->i_frame_size = p_sys->i_frame_length * sizeof(int16_t) * p_enc->fmt_in.audio.i_channels; - p_sys->p_buffer = malloc( p_sys->i_frame_size ); - assert( p_sys->p_buffer ); + p_sys->p_buffer = xmalloc( p_sys->i_frame_size ); /* Create and store headers */ pp_header[0] = speex_header_to_packet( &p_sys->header, &pi_header[0] ); @@ -1014,8 +1007,7 @@ static int OpenEncoder( vlc_object_t *p_this ) pi_header[1] = sizeof("ENCODER=VLC media player"); p_enc->fmt_out.i_extra = 3 * 2 + pi_header[0] + pi_header[1]; - p_extra = p_enc->fmt_out.p_extra = malloc( p_enc->fmt_out.i_extra ); - assert( p_extra ); + p_extra = p_enc->fmt_out.p_extra = xmalloc( p_enc->fmt_out.i_extra ); for( i = 0; i < 2; i++ ) { *(p_extra++) = pi_header[i] >> 8; diff --git a/modules/codec/subtitles/subsdec.c b/modules/codec/subtitles/subsdec.c index d1b7572e44..121f171705 100644 --- a/modules/codec/subtitles/subsdec.c +++ b/modules/codec/subtitles/subsdec.c @@ -31,8 +31,6 @@ # include "config.h" #endif -#include - #include "subsdec.h" #include @@ -456,12 +454,10 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block ) { size_t inbytes_left = strlen( psz_subtitle ); size_t outbytes_left = 6 * inbytes_left; - char *psz_new_subtitle = malloc( outbytes_left + 1 ); + char *psz_new_subtitle = xmalloc( outbytes_left + 1 ); char *psz_convert_buffer_out = psz_new_subtitle; const char *psz_convert_buffer_in = psz_subtitle; - assert( psz_new_subtitle ); - size_t ret = vlc_iconv( p_sys->iconv_handle, &psz_convert_buffer_in, &inbytes_left, &psz_convert_buffer_out, &outbytes_left ); diff --git a/modules/codec/theora.c b/modules/codec/theora.c index 8f5e328f02..0815212b66 100644 --- a/modules/codec/theora.c +++ b/modules/codec/theora.c @@ -28,14 +28,11 @@ # include "config.h" #endif -#include - #include #include #include #include #include -#include #include #include @@ -218,9 +215,8 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) /* Backup headers as extra data */ uint8_t *p_extra; - p_dec->fmt_in.p_extra = realloc_or_free( p_dec->fmt_in.p_extra, + p_dec->fmt_in.p_extra = xrealloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra + oggpacket.bytes + 2 ); - assert( p_dec->fmt_in.p_extra ); p_extra = ((uint8_t *)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra; *(p_extra++) = oggpacket.bytes >> 8; *(p_extra++) = oggpacket.bytes & 0xFF; @@ -407,9 +403,8 @@ static int ProcessHeaders( decoder_t *p_dec ) else { p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra; - p_dec->fmt_out.p_extra = realloc_or_free( p_dec->fmt_out.p_extra, + p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra ); - assert( p_dec->fmt_out.p_extra ); memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra ); } @@ -710,9 +705,8 @@ static int OpenEncoder( vlc_object_t *p_this ) else if( i == 1 ) theora_encode_comment( &p_sys->tc, &header ); else if( i == 2 ) theora_encode_tables( &p_sys->td, &header ); - p_enc->fmt_out.p_extra = realloc_or_free( p_enc->fmt_out.p_extra, + p_enc->fmt_out.p_extra = xrealloc( p_enc->fmt_out.p_extra, p_enc->fmt_out.i_extra + header.bytes ); - assert( p_enc->fmt_out.p_extra ); p_extra = p_enc->fmt_out.p_extra; p_extra += p_enc->fmt_out.i_extra + (i-3)*2; p_enc->fmt_out.i_extra += header.bytes; diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c index d4598129c7..cb9ecd3ef9 100644 --- a/modules/codec/vorbis.c +++ b/modules/codec/vorbis.c @@ -31,15 +31,12 @@ # include "config.h" #endif -#include - #include #include #include #include #include #include -#include #include @@ -321,9 +318,8 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) /* Backup headers as extra data */ uint8_t *p_extra; - p_dec->fmt_in.p_extra = realloc_or_free( p_dec->fmt_in.p_extra, + p_dec->fmt_in.p_extra = xrealloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra + oggpacket.bytes + 2 ); - assert( p_dec->fmt_in.p_extra ); p_extra = (uint8_t *)p_dec->fmt_in.p_extra + p_dec->fmt_in.i_extra; *(p_extra++) = oggpacket.bytes >> 8; *(p_extra++) = oggpacket.bytes & 0xFF; @@ -457,9 +453,8 @@ static int ProcessHeaders( decoder_t *p_dec ) else { p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra; - p_dec->fmt_out.p_extra = realloc_or_free( p_dec->fmt_out.p_extra, + p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra ); - assert( p_dec->fmt_out.p_extra ); memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra ); } @@ -882,8 +877,7 @@ static int OpenEncoder( vlc_object_t *p_this ) &header[0], &header[1], &header[2]); p_enc->fmt_out.i_extra = 3 * 2 + header[0].bytes + header[1].bytes + header[2].bytes; - p_extra = p_enc->fmt_out.p_extra = malloc( p_enc->fmt_out.i_extra ); - assert( p_extra ); + p_extra = p_enc->fmt_out.p_extra = xmalloc( p_enc->fmt_out.i_extra ); for( i = 0; i < 3; i++ ) { *(p_extra++) = header[i].bytes >> 8; diff --git a/modules/control/http/macro.c b/modules/control/http/macro.c index fb2802b706..f8d322607c 100644 --- a/modules/control/http/macro.c +++ b/modules/control/http/macro.c @@ -26,12 +26,9 @@ # include "config.h" #endif -#include - #include "http.h" #include "macros.h" #include -#include static int MacroParse( macro_t *m, char *psz_src ) { @@ -152,8 +149,7 @@ static void MacroDo( httpd_file_sys_t *p_args, { \ int __i__ = *pp_dst - *pp_data; \ *pi_data += (l); \ - *pp_data = realloc_or_free( *pp_data, *pi_data ); \ - assert( *pp_data ); \ + *pp_data = xrealloc( *pp_data, *pi_data ); \ *pp_dst = (*pp_data) + __i__; \ } #define PRINT( str ) \ @@ -369,9 +365,8 @@ static void MacroDo( httpd_file_sys_t *p_args, if( !*item ) continue; int i_item = atoi( item ); - p_items = realloc_or_free( p_items, + p_items = xrealloc( p_items, (i_nb_items + 1) * sizeof(*p_items) ); - assert( p_items ); p_items[i_nb_items] = i_item; i_nb_items++; } @@ -407,9 +402,8 @@ static void MacroDo( httpd_file_sys_t *p_args, if( !*item ) continue; int i_item = atoi( item ); - p_items = realloc_or_free( p_items, + p_items = xrealloc( p_items, (i_nb_items + 1) * sizeof(*p_items) ); - assert( p_items ); p_items[i_nb_items] = i_item; i_nb_items++; } @@ -549,13 +543,11 @@ static void MacroDo( httpd_file_sys_t *p_args, }; vlm_message_t *vlm_answer; char name[512]; - char *psz = malloc( strlen( p_request ) + 1000 ); + char *psz = xmalloc( strlen( p_request ) + 1000 ); char *p = psz; char *vlm_error; int i; - assert( psz ); - if( p_intf->p_sys->p_vlm == NULL ) p_intf->p_sys->p_vlm = vlm_New( p_intf ); @@ -885,11 +877,9 @@ void Execute( httpd_file_sys_t *p_args, char *src, *dup, *end; char *dst = *pp_dst; - src = dup = malloc( _end - _src + 1 ); + src = dup = xmalloc( _end - _src + 1 ); end = src +( _end - _src ); - assert( src ); - memcpy( src, _src, _end - _src ); *end = '\0'; @@ -1128,8 +1118,7 @@ void Execute( httpd_file_sys_t *p_args, int i_index = dst - *pp_data; *pi_data += i_copy; - *pp_data = realloc_or_free( *pp_data, *pi_data ); - assert( *pp_data ); + *pp_data = xrealloc( *pp_data, *pi_data ); dst = (*pp_data) + i_index; memcpy( dst, src, i_copy ); diff --git a/modules/control/http/mvar.c b/modules/control/http/mvar.c index 9e9deb9b1c..e0926f668f 100644 --- a/modules/control/http/mvar.c +++ b/modules/control/http/mvar.c @@ -29,10 +29,6 @@ #include "http.h" #include -#include - -#include - /* Utility function for scandir */ static int Filter( const char *foo ) { @@ -56,8 +52,7 @@ mvar_t *mvar_New( const char *name, const char *value ) v->value = strdup( value ? value : "" ); v->i_field = 0; - v->field = malloc( sizeof( mvar_t * ) ); - assert( v->field ); + v->field = xmalloc( sizeof( mvar_t * ) ); v->field[0] = NULL; return v; @@ -80,9 +75,7 @@ void mvar_Delete( mvar_t *v ) void mvar_AppendVar( mvar_t *v, mvar_t *f ) { - v->field = realloc_or_free( v->field, - sizeof( mvar_t * ) * ( v->i_field + 2 ) ); - assert( v->field ); + v->field = xrealloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) ); v->field[v->i_field] = f; v->i_field++; } @@ -103,9 +96,7 @@ mvar_t *mvar_Duplicate( const mvar_t *v ) void mvar_PushVar( mvar_t *v, mvar_t *f ) { - v->field = realloc_or_free( v->field, - sizeof( mvar_t * ) * ( v->i_field + 2 ) ); - assert( v->field ); + v->field = xrealloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) ); if( v->i_field > 0 ) { memmove( &v->field[1], &v->field[0], sizeof( mvar_t * ) * v->i_field ); diff --git a/modules/control/http/util.c b/modules/control/http/util.c index 70288be4e4..d7d7cb4bf7 100644 --- a/modules/control/http/util.c +++ b/modules/control/http/util.c @@ -27,12 +27,9 @@ # include "config.h" #endif -#include - #include #include "http.h" #include -#include /**************************************************************************** * File and directory functions @@ -93,14 +90,12 @@ int FileLoad( FILE *f, char **pp_data, int *pi_data ) /* just load the file */ *pi_data = 0; - *pp_data = malloc( 1025 ); /* +1 for \0 */ - assert( *pp_data ); + *pp_data = xmalloc( 1025 ); /* +1 for \0 */ while( ( i_read = fread( &(*pp_data)[*pi_data], 1, 1024, f ) ) == 1024 ) { *pi_data += 1024; - *pp_data = realloc_or_free( *pp_data, *pi_data + 1025 ); - assert( *pp_data ); + *pp_data = xrealloc( *pp_data, *pi_data + 1025 ); } if( i_read > 0 ) { @@ -238,10 +233,9 @@ int ParseDirectory( intf_thread_t *p_intf, char *psz_root, } if( f == NULL ) { - f = malloc( sizeof( httpd_file_sys_t ) ); + f = xmalloc( sizeof( httpd_file_sys_t ) ); f->b_handler = false; } - assert( f ); f->p_intf = p_intf; f->p_file = NULL; @@ -927,8 +921,7 @@ char *RealPath( const char *psz_src ) char *p; int i_len = strlen(psz_src); - psz_dir = malloc( i_len + 2 ); - assert( psz_dir ); + psz_dir = xmalloc( i_len + 2 ); strcpy( psz_dir, psz_src ); /* Add a trailing sep to ease the .. step */ diff --git a/modules/control/rc.c b/modules/control/rc.c index cf69965ac6..d57151b1e2 100644 --- a/modules/control/rc.c +++ b/modules/control/rc.c @@ -30,11 +30,8 @@ # include "config.h" #endif -#include - #include #include -#include #include /* ENOMEM */ #include @@ -2109,9 +2106,7 @@ static input_item_t *parse_MRL( intf_thread_t *p_intf, char *psz_mrl ) else if( *psz_item ) { i_options++; - ppsz_options = realloc_or_free( ppsz_options, - i_options * sizeof(char *) ); - assert( ppsz_options ); + ppsz_options = xrealloc( ppsz_options, i_options * sizeof(char *) ); ppsz_options[i_options - 1] = &psz_item[1]; } diff --git a/modules/control/telnet.c b/modules/control/telnet.c index 866200dca6..6718403255 100644 --- a/modules/control/telnet.c +++ b/modules/control/telnet.c @@ -30,13 +30,10 @@ # include "config.h" #endif -#include - #include #include #include #include -#include #include #include @@ -575,8 +572,7 @@ static char *MessageToString( vlm_message_t *message, int i_level ) } i_message += strlen( message->psz_name ) + i_level * sizeof( " " ) + 1; - psz_message = malloc( i_message ); - assert( psz_message ); + psz_message = xmalloc( i_message ); *psz_message = 0; for( i = 0; i < i_level; i++ ) strcat( psz_message, " " ); strcat( psz_message, message->psz_name ); @@ -585,8 +581,7 @@ static char *MessageToString( vlm_message_t *message, int i_level ) { i_message += sizeof( " : " ) + strlen( message->psz_value ) + sizeof( STRING_CR ); - psz_message = realloc_or_free( psz_message, i_message ); - assert( psz_message ); + psz_message = xrealloc( psz_message, i_message ); strcat( psz_message, " : " ); strcat( psz_message, message->psz_value ); strcat( psz_message, STRING_CR ); @@ -594,8 +589,7 @@ static char *MessageToString( vlm_message_t *message, int i_level ) else { i_message += sizeof( STRING_CR ); - psz_message = realloc_or_free( psz_message, i_message ); - assert( psz_message ); + psz_message = xrealloc( psz_message, i_message ); strcat( psz_message, STRING_CR ); } @@ -605,8 +599,7 @@ static char *MessageToString( vlm_message_t *message, int i_level ) MessageToString( message->child[i], i_level + 1 ); i_message += strlen( child_message ); - psz_message = realloc_or_free( psz_message, i_message ); - assert( psz_message ); + psz_message = xrealloc( psz_message, i_message ); strcat( psz_message, child_message ); free( child_message ); } diff --git a/modules/demux/asademux.c b/modules/demux/asademux.c index 0739b58a76..fa7303bf4d 100644 --- a/modules/demux/asademux.c +++ b/modules/demux/asademux.c @@ -35,21 +35,23 @@ #include #include #include -#include #include #include -#include #include "asademux.h" #define MAXDELTA 4 /**< nr of times kept for delta backref */ #define MAXGROUP 24 /**< maximum number of regex match groups */ -#define xmalloc malloc -#define xrealloc realloc_or_free #define xfree free -#define xstrdup strdup +static inline char *xstrdup(const char *str) +{ + char *ret = strdup (str); + if (unlikely(ret == NULL)) + abort(); + return ret; +} /** state of a running import */ struct asa_import_state { @@ -249,7 +251,6 @@ static int asai_select (struct asa_import_state *state, if (state->selstr) xfree(state->selstr); state->selstr = xstrdup(state->matches[insn->v.select]); - assert(state->selstr); state->sellen = strlen(state->selstr); return 0; } @@ -265,7 +266,6 @@ static ptrdiff_t asai_process_replace(struct asa_import_state *state, newstr_size = v[0] * 2; newstr = (char *)xmalloc(newstr_size); - assert(newstr); memcpy(newstr, state->selstr, v[0]); newpos = v[0]; @@ -290,7 +290,6 @@ static ptrdiff_t asai_process_replace(struct asa_import_state *state, if (need > avail) { newstr_size += need - avail + 256; newstr = (char *)xrealloc(newstr, newstr_size); - assert(newstr); } memcpy(newstr + newpos, src, need); newpos += need; @@ -298,7 +297,6 @@ static ptrdiff_t asai_process_replace(struct asa_import_state *state, firstold = newpos; newstr_size = newpos + state->sellen - v[1]; newstr = (char *)xrealloc(newstr, newstr_size + 1); - assert(newstr); memcpy(newstr + newpos, state->selstr + v[1], state->sellen - v[1] + 1); state->selstr = newstr; @@ -358,7 +356,6 @@ static void asai_set_matches(struct asa_import_state *state, if (state->selstr) xfree(state->selstr); state->selstr = xstrdup(state->matches[0]); - assert(state->selstr); state->sellen = strlen(state->selstr); } @@ -390,7 +387,6 @@ static int asai_append (struct asa_import_state *state, { state->out = (char *)xrealloc(state->out, state->outlen + state->sellen + 1); - assert(state->out); memcpy(state->out + state->outlen, state->selstr, state->sellen); state->outlen += state->sellen; state->out[state->outlen] = '\0'; diff --git a/modules/demux/gme.cpp b/modules/demux/gme.cpp index d0ec1ce931..dd3ac00a14 100644 --- a/modules/demux/gme.cpp +++ b/modules/demux/gme.cpp @@ -148,12 +148,17 @@ static int Open( vlc_object_t *p_this ) p_demux->pf_demux = Demux; p_demux->pf_control = Control; p_demux->p_sys = p_sys = (demux_sys_t *)malloc( sizeof( demux_sys_t ) ); - assert(p_sys); + if( unlikely( !p_sys ) ) + return VLC_ENOMEM; msg_Dbg( p_demux, "loading complete file (could be long)" ); p_sys->i_data = stream_Size( p_demux->s ); p_sys->p_data = (uint8_t *)malloc( p_sys->i_data ); - assert(p_sys->p_data); + if( unlikely( !p_sys->p_data ) ) + { + free( p_sys ); + return VLC_ENOMEM; + } p_sys->i_data = stream_Read( p_demux->s, p_sys->p_data, p_sys->i_data ); if( p_sys->i_data <= 0 ) { @@ -456,8 +461,7 @@ switch( i_query ) int *pi_int = (int*)va_arg( args, int* ); *pi_int = p_sys->i_tracks; - *ppp_title = (input_title_t**)malloc( sizeof( input_title_t**) * p_sys->i_tracks ); - assert( *ppp_sitle ); + *ppp_title = (input_title_t**)xmalloc( sizeof( input_title_t**) * p_sys->i_tracks ); for( int i = 0; i < p_sys->i_tracks; i++ ) { @@ -501,8 +505,7 @@ static void inflate_gzbuf(uint8_t * p_buffer, size_t i_size, uint8_t ** pp_obuff memset(&z_str, 0, sizeof(z_str)); out_size = i_size * 2; - out_buffer = (uint8_t*)malloc(out_size); - assert(out_buffer); + out_buffer = (uint8_t*)xmalloc(out_size); z_str.next_in = (unsigned char*)p_buffer; z_str.avail_in = i_size; @@ -524,8 +527,7 @@ static void inflate_gzbuf(uint8_t * p_buffer, size_t i_size, uint8_t ** pp_obuff case Z_BUF_ERROR: offset = z_str.next_out - out_buffer; out_size *= 2; - out_buffer = (uint8_t *)realloc_or_free(out_buffer, out_size); - assert(out_buffer); + out_buffer = (uint8_t *)xrealloc(out_buffer, out_size); z_str.next_out = out_buffer + offset; z_str.avail_out = out_size - offset; break; @@ -540,8 +542,7 @@ static void inflate_gzbuf(uint8_t * p_buffer, size_t i_size, uint8_t ** pp_obuff inflateEnd(&z_str); - out_buffer = (uint8_t *)realloc_or_free(out_buffer, *pi_osize); - assert(out_buffer); + out_buffer = (uint8_t *)xrealloc(out_buffer, *pi_osize); (*pp_obuffer) = out_buffer; } #endif diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp index cdf6adbe6b..abc0eddec9 100644 --- a/modules/demux/live555.cpp +++ b/modules/demux/live555.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include @@ -368,8 +367,7 @@ static int Open ( vlc_object_t *p_this ) } i_sdp_max += 1000; - p_sdp = (uint8_t*)realloc_or_free( p_sdp, i_sdp_max ); - assert( p_sdp ); + p_sdp = (uint8_t*)xrealloc( p_sdp, i_sdp_max ); } p_sys->p_sdp = (char*)p_sdp; } @@ -868,8 +866,7 @@ static int SessionsSetup( demux_t *p_demux ) i_extra ) ) ) { tk->fmt.i_extra = i_extra; - tk->fmt.p_extra = malloc( i_extra ); - assert( tk->fmt.p_extra ); + tk->fmt.p_extra = xmalloc( i_extra ); memcpy( tk->fmt.p_extra, p_extra, i_extra ); delete[] p_extra; } @@ -889,8 +886,7 @@ static int SessionsSetup( demux_t *p_demux ) i_extra ) ) ) { tk->fmt.i_extra = i_extra; - tk->fmt.p_extra = malloc( i_extra ); - assert( tk->fmt.p_extra ); + tk->fmt.p_extra = xmalloc( i_extra ); memcpy( tk->fmt.p_extra, p_extra, i_extra ); delete[] p_extra; } @@ -948,8 +944,7 @@ static int SessionsSetup( demux_t *p_demux ) i_extra ) ) ) { tk->fmt.i_extra = i_extra; - tk->fmt.p_extra = malloc( i_extra ); - assert( tk->fmt.p_extra ); + tk->fmt.p_extra = xmalloc( i_extra ); memcpy( tk->fmt.p_extra, p_extra, i_extra ); delete[] p_extra; @@ -970,8 +965,7 @@ static int SessionsSetup( demux_t *p_demux ) i_extra ) ) ) { tk->fmt.i_extra = i_extra; - tk->fmt.p_extra = malloc( i_extra ); - assert( tk->fmt.p_extra ); + tk->fmt.p_extra = xmalloc( i_extra ); memcpy( tk->fmt.p_extra, p_extra, i_extra ); delete[] p_extra; } @@ -1034,9 +1028,8 @@ static int SessionsSetup( demux_t *p_demux ) if( tk->p_es || tk->b_quicktime || tk->b_muxed || tk->b_asf ) { /* Append */ - p_sys->track = (live_track_t**)realloc_or_free( p_sys->track, + p_sys->track = (live_track_t**)xrealloc( p_sys->track, sizeof( live_track_t ) * ( p_sys->i_track + 1 ) ); - assert( p_sys->track ); p_sys->track[p_sys->i_track++] = tk; } else @@ -1625,8 +1618,7 @@ static void StreamRead( void *p_private, unsigned int i_size, atomLength <= INT_MAX ) { tk->fmt.i_extra = atomLength-8; - tk->fmt.p_extra = malloc( tk->fmt.i_extra ); - assert( tk->fmt.p_extra ); + tk->fmt.p_extra = xmalloc( tk->fmt.i_extra ); memcpy(tk->fmt.p_extra, pos+8, atomLength-8); break; } @@ -1636,8 +1628,7 @@ static void StreamRead( void *p_private, unsigned int i_size, else { tk->fmt.i_extra = qtState.sdAtomSize - 16; - tk->fmt.p_extra = malloc( tk->fmt.i_extra ); - assert( tk->fmt.p_extra ); + tk->fmt.p_extra = xmalloc( tk->fmt.i_extra ); memcpy( tk->fmt.p_extra, &sdAtom[12], tk->fmt.i_extra ); } } diff --git a/modules/demux/mkv/chapters.cpp b/modules/demux/mkv/chapters.cpp index 1272eb1b63..f92143315f 100644 --- a/modules/demux/mkv/chapters.cpp +++ b/modules/demux/mkv/chapters.cpp @@ -26,9 +26,6 @@ #include "chapter_command.hpp" -#include -#include - chapter_item_c::~chapter_item_c() { std::vector::iterator index = codecs.begin(); @@ -65,9 +62,8 @@ int chapter_item_c::PublishChapters( input_title_t & title, int & i_user_chapter // A start time of '0' is ok. A missing ChapterTime element is ok, too, because '0' is its default value. title.i_seekpoint++; - title.seekpoint = (seekpoint_t**)realloc_or_free( title.seekpoint, + title.seekpoint = (seekpoint_t**)xrealloc( title.seekpoint, title.i_seekpoint * sizeof( seekpoint_t* ) ); - assert( title.seekpoint ); title.seekpoint[title.i_seekpoint-1] = sk; if ( b_user_display ) diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp index 7c6f2b6b1c..db9ce1c6b1 100644 --- a/modules/demux/mkv/matroska_segment.cpp +++ b/modules/demux/mkv/matroska_segment.cpp @@ -28,9 +28,6 @@ #include "demux.hpp" -#include -#include - extern "C" { #include "../vobsub.h" } @@ -182,9 +179,8 @@ void matroska_segment_c::LoadCues( KaxCues *cues ) if( i_index >= i_index_max ) { i_index_max += 1024; - p_indexes = (mkv_index_t*)realloc_or_free( p_indexes, + p_indexes = (mkv_index_t*)xrealloc( p_indexes, sizeof( mkv_index_t ) * i_index_max ); - assert( p_indexes ); } #undef idx } @@ -377,9 +373,8 @@ void matroska_segment_c::IndexAppendCluster( KaxCluster *cluster ) if( i_index >= i_index_max ) { i_index_max += 1024; - p_indexes = (mkv_index_t*)realloc_or_free( p_indexes, + p_indexes = (mkv_index_t*)xrealloc( p_indexes, sizeof( mkv_index_t ) * i_index_max ); - assert( p_indexes ); } #undef idx } @@ -671,8 +666,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) tracks[i_track]->fmt.i_extra = GetDWLE( &p_bih->biSize ) - sizeof( BITMAPINFOHEADER ); if( tracks[i_track]->fmt.i_extra > 0 ) { - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->fmt.i_extra ); memcpy( tracks[i_track]->fmt.p_extra, &p_bih[1], tracks[i_track]->fmt.i_extra ); } } @@ -723,8 +717,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) + 6; if( i_size1 > 0 && i_size2 > 0 && i_size3 > 0 ) { tracks[i_track]->fmt.p_extra = - malloc( tracks[i_track]->fmt.i_extra ); - assert( tracks[i_track]->fmt.p_extra ); + xmalloc( tracks[i_track]->fmt.i_extra ); uint8_t *p_out = (uint8_t*)tracks[i_track]->fmt.p_extra; *p_out++ = (i_size1>>8) & 0xFF; *p_out++ = i_size1 & 0xFF; @@ -794,15 +787,13 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) else tracks[i_track]->fmt.i_codec = VLC_CODEC_MP4V; tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data; - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data ); memcpy( tracks[i_track]->fmt.p_extra,tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data ); } } else if( !strcmp( tracks[i_track]->psz_codec, "V_QUICKTIME" ) ) { - MP4_Box_t *p_box = (MP4_Box_t*)malloc( sizeof( MP4_Box_t ) ); - assert( p_box ); + MP4_Box_t *p_box = (MP4_Box_t*)xmalloc( sizeof( MP4_Box_t ) ); stream_t *p_mp4_stream = stream_MemoryNew( VLC_OBJECT(&sys.demuxer), tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data, @@ -814,8 +805,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) tracks[i_track]->fmt.video.i_width = p_box->data.p_sample_vide->i_width; tracks[i_track]->fmt.video.i_height = p_box->data.p_sample_vide->i_height; tracks[i_track]->fmt.i_extra = p_box->data.p_sample_vide->i_qt_image_description; - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->fmt.i_extra ); memcpy( tracks[i_track]->fmt.p_extra, p_box->data.p_sample_vide->p_qt_image_description, tracks[i_track]->fmt.i_extra ); MP4_FreeBox_sample_vide( p_box ); } @@ -847,8 +837,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) tracks[i_track]->fmt.i_extra = GetWLE( &p_wf->cbSize ); if( tracks[i_track]->fmt.i_extra > 0 ) { - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->fmt.i_extra ); memcpy( tracks[i_track]->fmt.p_extra, &p_wf[1], tracks[i_track]->fmt.i_extra ); } } @@ -885,8 +874,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) { tracks[i_track]->fmt.i_codec = VLC_CODEC_FLAC; tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data; - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data ); memcpy( tracks[i_track]->fmt.p_extra,tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data ); } else if( !strcmp( tracks[i_track]->psz_codec, "A_VORBIS" ) ) @@ -915,8 +903,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) i_size[2] = tracks[i_track]->i_extra_data - i_offset - i_size[0] - i_size[1]; tracks[i_track]->fmt.i_extra = 3 * 2 + i_size[0] + i_size[1] + i_size[2]; - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->fmt.i_extra ); p_extra = (uint8_t *)tracks[i_track]->fmt.p_extra; i_extra = 0; for( i = 0; i < 3; i++ ) { @@ -973,8 +960,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) msg_Dbg( &sys.demuxer, "profile=%d srate=%d", i_profile, i_srate ); tracks[i_track]->fmt.i_extra = sbr ? 5 : 2; - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->fmt.i_extra ); ((uint8_t*)tracks[i_track]->fmt.p_extra)[0] = ((i_profile + 1) << 3) | ((i_srate&0xe) >> 1); ((uint8_t*)tracks[i_track]->fmt.p_extra)[1] = ((i_srate & 0x1) << 7) | (tracks[i_track]->fmt.audio.i_channels << 3); if (sbr != 0) @@ -993,16 +979,14 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) { tracks[i_track]->fmt.i_codec = VLC_CODEC_MP4A; tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data; - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data ); memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data ); } else if( !strcmp( tracks[i_track]->psz_codec, "A_WAVPACK4" ) ) { tracks[i_track]->fmt.i_codec = VLC_CODEC_WAVPACK; tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data; - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data ); memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data ); } else if( !strcmp( tracks[i_track]->psz_codec, "A_TTA1" ) ) @@ -1011,15 +995,13 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) p_fmt->i_extra = p_tk->i_extra_data; if( p_fmt->i_extra > 0 ) { - p_fmt->p_extra = malloc( p_tk->i_extra_data ); - assert( p_fmt->p_extra ); + p_fmt->p_extra = xmalloc( p_tk->i_extra_data ); memcpy( p_fmt->p_extra, p_tk->p_extra_data, p_tk->i_extra_data ); } else { p_fmt->i_extra = 30; - p_fmt->p_extra = malloc( p_fmt->i_extra ); - assert( p_fmt->p_extra ); + p_fmt->p_extra = xmalloc( p_fmt->i_extra ); uint8_t *p_extra = (uint8_t*)p_fmt->p_extra; memcpy( &p_extra[ 0], "TTA1", 4 ); SetWLE( &p_extra[ 4], 1 ); @@ -1078,8 +1060,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) msg_Dbg( &sys.demuxer, "kate last header (%d) is %d bytes", num_headers-1, pi_size[num_headers-1]); tracks[i_track]->fmt.i_extra = 1 + num_headers * 2 + size_so_far + pi_size[num_headers-1]; - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->fmt.i_extra ); p_extra = (uint8_t *)tracks[i_track]->fmt.p_extra; i_extra = 0; @@ -1113,8 +1094,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) if( tracks[i_track]->i_extra_data ) { tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data; - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data ); memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data ); } } @@ -1128,8 +1108,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) if( tracks[i_track]->i_extra_data ) { tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data; - tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data ); - assert( tracks[i_track]->fmt.p_extra ); + tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data ); memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data ); } } diff --git a/modules/demux/nuv.c b/modules/demux/nuv.c index 0230ec20c3..257efd6e7d 100644 --- a/modules/demux/nuv.c +++ b/modules/demux/nuv.c @@ -29,12 +29,9 @@ # include "config.h" #endif -#include - #include #include #include -#include /* TODO: * - test @@ -926,9 +923,8 @@ static void demux_IndexAppend( demux_index_t *p_idx, else { p_idx->i_idx_max += 1000; - p_idx->idx = realloc_or_free( p_idx->idx, + p_idx->idx = xrealloc( p_idx->idx, p_idx->i_idx_max*sizeof(demux_index_entry_t)); - assert( p_idx->idx ); } } diff --git a/modules/demux/playlist/asx.c b/modules/demux/playlist/asx.c index b996b7e0e3..2c3736ff5a 100644 --- a/modules/demux/playlist/asx.c +++ b/modules/demux/playlist/asx.c @@ -31,8 +31,6 @@ # include "config.h" #endif -#include - #include #include @@ -40,7 +38,6 @@ #include #include "playlist.h" #include -#include struct demux_sys_t { @@ -245,8 +242,7 @@ static int Demux( demux_t *p_demux ) int64_t i_pos = 0; p_sys->i_data_len = stream_Size( p_demux->s ) + 1; /* This is a cheat to prevent unnecessary realloc */ if( p_sys->i_data_len <= 0 || p_sys->i_data_len > 16384 ) p_sys->i_data_len = 1024; - p_sys->psz_data = malloc( p_sys->i_data_len +1); - assert( p_sys->psz_data ); + p_sys->psz_data = xmalloc( p_sys->i_data_len +1); /* load the complete file */ for( ;; ) @@ -258,9 +254,8 @@ static int Demux( demux_t *p_demux ) i_pos += i_read; p_sys->i_data_len <<= 1 ; - p_sys->psz_data = realloc_or_free( p_sys->psz_data, + p_sys->psz_data = xrealloc( p_sys->psz_data, p_sys->i_data_len * sizeof( char * ) + 1 ); - assert( p_sys->psz_data ); } if( p_sys->i_data_len <= 0 ) return -1; } @@ -318,8 +313,7 @@ static int Demux( demux_t *p_demux ) i_strlen = psz_parse-psz_backup; if( i_strlen < 1 ) continue; msg_Dbg( p_demux, "param name strlen: %d", i_strlen); - psz_string = malloc( i_strlen + 1); - assert( psz_string ); + psz_string = xmalloc( i_strlen + 1); memcpy( psz_string, psz_backup, i_strlen ); psz_string[i_strlen] = '\0'; msg_Dbg( p_demux, "param name: %s", psz_string); @@ -341,8 +335,7 @@ static int Demux( demux_t *p_demux ) i_strlen = psz_parse-psz_backup; if( i_strlen < 1 ) continue; msg_Dbg( p_demux, "param value strlen: %d", i_strlen); - psz_string = malloc( i_strlen +1); - assert( psz_string ); + psz_string = xmalloc( i_strlen +1); memcpy( psz_string, psz_backup, i_strlen ); psz_string[i_strlen] = '\0'; msg_Dbg( p_demux, "param value: %s", psz_string); @@ -467,8 +460,7 @@ static int Demux( demux_t *p_demux ) { i_strlen = psz_parse-psz_backup; if( i_strlen < 1 ) continue; - psz_string = malloc( i_strlen +1); - assert( psz_string ); + psz_string = xmalloc( i_strlen +1); memcpy( psz_string, psz_backup, i_strlen ); psz_string[i_strlen] = '\0'; input_item_t *p_input; @@ -640,8 +632,7 @@ static int Demux( demux_t *p_demux ) } free( psz_href ); - psz_href = malloc( i_strlen +1); - assert( psz_string ); + psz_href = xmalloc( i_strlen +1); memcpy( psz_href, psz_backup, i_strlen ); psz_href[i_strlen] = '\0'; psz_tmp = psz_href + (i_strlen-1); diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c index f791ddd7d6..06bfaae118 100644 --- a/modules/demux/subtitle.c +++ b/modules/demux/subtitle.c @@ -31,8 +31,6 @@ # include "config.h" #endif -#include - #include #include #include @@ -1063,16 +1061,11 @@ static int ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle, free( psz_text ); /* All the other stuff we add to the header field */ - if( !p_sys->psz_header ) - p_sys->psz_header = strdup( "" ); - if( !p_sys->psz_header ) + char *psz_header; + if( asprintf( &psz_header, "%s%s\n", + p_sys->psz_header ? p_sys->psz_header : "", s ) == -1 ) return VLC_ENOMEM; - - p_sys->psz_header = realloc_or_free( p_sys->psz_header, - strlen( p_sys->psz_header ) + strlen( s ) + 2 ); - assert( p_sys->psz_header ); - strcat( p_sys->psz_header, s ); - strcat( p_sys->psz_header, "\n" ); + p_sys->psz_header = psz_header; } } @@ -1721,7 +1714,6 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) /* Directives are NOT parsed yet */ /* This has probably a better place in a decoder ? */ /* directive = malloc( strlen( psz_text ) + 1 ); - assert( directive ); if( sscanf( psz_text, "%s %[^\n\r]", directive, psz_text2 ) == 2 )*/ } diff --git a/modules/demux/ts.c b/modules/demux/ts.c index 7745445179..43d829eb4f 100644 --- a/modules/demux/ts.c +++ b/modules/demux/ts.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -516,10 +515,6 @@ static int Open( vlc_object_t *p_this ) char *psz_event_text = malloc(130); char *psz_ext_text = malloc(1025); - assert( psz_name ); - assert( psz_event_text ); - assert( psz_ext_text ); - // 2 bytes version Uimsbf (4,5) // 2 bytes reserved (6,7) // 2 bytes duration in minutes Uimsbf (8,9( @@ -623,8 +618,7 @@ static int Open( vlc_object_t *p_this ) { p_sys->i_ts_read = 1500 / p_sys->i_packet_size; } - p_sys->buffer = malloc( p_sys->i_packet_size * p_sys->i_ts_read ); - assert( p_sys->buffer ); + p_sys->buffer = xmalloc( p_sys->i_packet_size * p_sys->i_ts_read ); msg_Info( p_demux, "%s raw stream to file `%s' reading packets %d", b_append ? "appending" : "dumping", p_sys->psz_file, p_sys->i_ts_read ); @@ -1554,7 +1548,7 @@ static void PIDInit( ts_pid_t *pid, bool b_psi, ts_psi_t *p_owner ) if( !b_old_valid ) { - pid->psi = malloc( sizeof( ts_psi_t ) ); + pid->psi = xmalloc( sizeof( ts_psi_t ) ); if( pid->psi ) { pid->psi->handle = NULL; @@ -3024,9 +3018,8 @@ static void EITCallBack( demux_t *p_demux, { msg_Dbg( p_demux, " - text='%s'", psz_text ); - psz_extra = realloc_or_free( psz_extra, + psz_extra = xrealloc( psz_extra, strlen(psz_extra) + strlen(psz_text) + 1 ); - assert( psz_extra ); strcat( psz_extra, psz_text ); free( psz_text ); } @@ -3042,10 +3035,9 @@ static void EITCallBack( demux_t *p_demux, { msg_Dbg( p_demux, " - desc='%s' item='%s'", psz_dsc, psz_itm ); #if 0 - psz_extra = realloc_or_free( psz_extra, + psz_extra = xrealloc( psz_extra, strlen(psz_extra) + strlen(psz_dsc) + strlen(psz_itm) + 3 + 1 ); - assert( psz_extra ); strcat( psz_extra, "(" ); strcat( psz_extra, psz_dsc ); strcat( psz_extra, " " ); diff --git a/modules/demux/vobsub.c b/modules/demux/vobsub.c index 4c12222e5b..4b902d357f 100644 --- a/modules/demux/vobsub.c +++ b/modules/demux/vobsub.c @@ -29,11 +29,8 @@ # include "config.h" #endif -#include - #include #include -#include #include #include @@ -155,12 +152,17 @@ static int Open ( vlc_object_t *p_this ) p_demux->pf_demux = Demux; p_demux->pf_control = Control; p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); - assert( p_sys ); + if( unlikely( !p_sys ) ) + return VLC_ENOMEM; p_sys->i_length = 0; p_sys->p_vobsub_stream = NULL; p_sys->i_tracks = 0; - p_sys->track = (vobsub_track_t *)malloc( sizeof( vobsub_track_t ) ); - assert( p_sys->track ); + p_sys->track = malloc( sizeof( vobsub_track_t ) ); + if( unlikely( !p_sys->track ) ) + { + free( p_sys ); + return VLC_ENOMEM; + } p_sys->i_original_frame_width = -1; p_sys->i_original_frame_height = -1; p_sys->b_palette = false; @@ -527,9 +529,8 @@ static int ParseVobSubIDX( demux_t *p_demux ) language, &i_track_id ) == 2 ) { p_sys->i_tracks++; - p_sys->track = realloc_or_free( p_sys->track, + p_sys->track = xrealloc( p_sys->track, sizeof( vobsub_track_t ) * (p_sys->i_tracks + 1 ) ); - assert( p_sys->track ); language[2] = '\0'; /* Init the track */ @@ -537,8 +538,7 @@ static int ParseVobSubIDX( demux_t *p_demux ) memset( current_tk, 0, sizeof( vobsub_track_t ) ); current_tk->i_current_subtitle = 0; current_tk->i_subtitles = 0; - current_tk->p_subtitles = malloc( sizeof( subtitle_t ) );; - assert( current_tk->p_subtitles ); + current_tk->p_subtitles = xmalloc( sizeof( subtitle_t ) );; current_tk->i_track_id = i_track_id; current_tk->i_delay = (int64_t)0; @@ -590,9 +590,8 @@ static int ParseVobSubIDX( demux_t *p_demux ) current_tk->i_subtitles++; current_tk->p_subtitles = - realloc_or_free( current_tk->p_subtitles, + xrealloc( current_tk->p_subtitles, sizeof( subtitle_t ) * (current_tk->i_subtitles + 1 ) ); - assert( current_tk->p_subtitles ); current_sub = ¤t_tk->p_subtitles[current_tk->i_subtitles - 1]; current_sub->i_start = i_start * i_sign; diff --git a/modules/misc/freetype.c b/modules/misc/freetype.c index e6090cac54..76fd10b262 100644 --- a/modules/misc/freetype.c +++ b/modules/misc/freetype.c @@ -31,8 +31,6 @@ # include "config.h" #endif -#include - #include #include #include @@ -357,13 +355,11 @@ static int Create( vlc_object_t *p_this ) _("Building font cache"), _("Please wait while your font cache is rebuilt.\n" "This should take less than few minutes."), NULL ); - char *path; - path = (char *)malloc( PATH_MAX + 1 ); + char *path = xmalloc( PATH_MAX + 1 ); /* Fontconfig doesnt seem to know where windows fonts are with * current contribs. So just tell default windows font directory * is the place to search fonts */ - assert( path ); GetWindowsDirectory( path, PATH_MAX + 1 ); strcat( path, "\\fonts" ); if( p_dialog ) diff --git a/modules/misc/xml/xtag.c b/modules/misc/xml/xtag.c index de4b6ea82f..779fd40ae7 100644 --- a/modules/misc/xml/xtag.c +++ b/modules/misc/xml/xtag.c @@ -41,8 +41,6 @@ #include #include -#include - #undef XTAG_DEBUG typedef struct _XList @@ -351,8 +349,7 @@ static XList *xlist_append( XList *list, void *data ) { XList *l, *last; - l = (XList *)malloc( sizeof(XList) ); - assert( l ); + l = (XList *)xmalloc( sizeof(XList) ); l->prev = l->next = NULL; l->data = data; @@ -457,8 +454,7 @@ static char *xtag_slurp_to( XTagParser *parser, int good_end, int bad_end ) if( xi > 0 && xtag_cin (s[xi], good_end) ) { - ret = malloc( xi+1 ); - assert( ret ); + ret = xmalloc( xi+1 ); strncpy( ret, s, xi ); ret[xi] = '\0'; parser->start = &s[xi]; @@ -511,8 +507,7 @@ static char *xtag_slurp_quoted( XTagParser *parser ) } } - ret = malloc( xi+1 ); - assert( ret ); + ret = xmalloc( xi+1 ); strncpy( ret, s, xi ); ret[xi] = '\0'; parser->start = &s[xi]; @@ -564,8 +559,7 @@ static XAttribute *xtag_parse_attribute( XTagParser *parser ) goto err_free_name; } - attr = malloc( sizeof (*attr) ); - assert( attr ); + attr = xmalloc( sizeof (*attr) ); attr->name = name; attr->value = value; return attr; @@ -639,8 +633,7 @@ static XTag *xtag_parse_tag( XTagParser *parser ) if( (pcdata = xtag_slurp_to( parser, X_OPENTAG, X_NONE )) != NULL ) { - tag = malloc( sizeof(*tag) ); - assert( tag ); + tag = xmalloc( sizeof(*tag) ); tag->name = NULL; tag->pcdata = pcdata; tag->parent = parser->current_tag; @@ -694,8 +687,7 @@ static XTag *xtag_parse_tag( XTagParser *parser ) fprintf (stderr, "<%s ...\n", name); #endif - tag = malloc( sizeof(*tag) ); - assert( tag ); + tag = xmalloc( sizeof(*tag) ); tag->name = name; tag->pcdata = NULL; tag->parent = parser->current_tag; @@ -834,8 +826,7 @@ static XTag *xtag_new_parse( const char *s, int n ) return tag; } - wrapper = malloc( sizeof(XTag) ); - assert( wrapper ); + wrapper = xmalloc( sizeof(XTag) ); wrapper->name = NULL; wrapper->pcdata = NULL; wrapper->parent = NULL; diff --git a/modules/mux/avi.c b/modules/mux/avi.c index 31e6504998..f8cc85b230 100644 --- a/modules/mux/avi.c +++ b/modules/mux/avi.c @@ -31,14 +31,11 @@ # include "config.h" #endif -#include - #include #include #include #include #include -#include /***************************************************************************** * Module descriptor @@ -485,9 +482,8 @@ static int Mux ( sout_mux_t *p_mux ) if( p_sys->idx1.i_entry_count >= p_sys->idx1.i_entry_max ) { p_sys->idx1.i_entry_max += 10000; - p_sys->idx1.entry = realloc_or_free( p_sys->idx1.entry, + p_sys->idx1.entry = xrealloc( p_sys->idx1.entry, p_sys->idx1.i_entry_max * sizeof( avi_idx1_entry_t ) ); - assert( p_sys->idx1.entry ); } p_data = block_Realloc( p_data, 8, p_data->i_buffer ); diff --git a/modules/mux/mp4.c b/modules/mux/mp4.c index 13e72fa290..9050821d74 100644 --- a/modules/mux/mp4.c +++ b/modules/mux/mp4.c @@ -30,13 +30,10 @@ # include "config.h" #endif -#include - #include #include #include #include -#include #include @@ -600,9 +597,8 @@ again: if( p_stream->i_entry_count >= p_stream->i_entry_max - 1 ) { p_stream->i_entry_max += 1000; - p_stream->entry = realloc_or_free( p_stream->entry, + p_stream->entry = xrealloc( p_stream->entry, p_stream->i_entry_max * sizeof( mp4_entry_t ) ); - assert( p_stream->entry ); } /* update */ @@ -1950,8 +1946,7 @@ static void bo_init( bo_t *p_bo, int i_size, uint8_t *p_buffer, if( !p_buffer ) { p_bo->i_buffer_size = __MAX( i_size, 1024 ); - p_bo->p_buffer = malloc( p_bo->i_buffer_size ); - assert( p_bo->p_buffer ); + p_bo->p_buffer = xmalloc( p_bo->i_buffer_size ); } else { @@ -1972,8 +1967,7 @@ static void bo_add_8( bo_t *p_bo, uint8_t i ) else if( p_bo->b_grow ) { p_bo->i_buffer_size += 1024; - p_bo->p_buffer = realloc_or_free( p_bo->p_buffer, p_bo->i_buffer_size ); - assert( p_bo->p_buffer ); + p_bo->p_buffer = xrealloc( p_bo->p_buffer, p_bo->i_buffer_size ); p_bo->p_buffer[p_bo->i_buffer] = i; } diff --git a/modules/mux/ogg.c b/modules/mux/ogg.c index 233c99714d..7b45d54571 100644 --- a/modules/mux/ogg.c +++ b/modules/mux/ogg.c @@ -30,14 +30,11 @@ # include "config.h" #endif -#include - #include #include #include #include #include -#include #include @@ -538,9 +535,8 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) /* move input in delete queue */ if( !p_stream->b_new ) { - p_sys->pp_del_streams = realloc_or_free( p_sys->pp_del_streams, + p_sys->pp_del_streams = xrealloc( p_sys->pp_del_streams, (p_sys->i_del_streams + 1) * sizeof(ogg_stream_t *) ); - assert( p_sys->pp_del_streams ); p_sys->pp_del_streams[p_sys->i_del_streams++] = p_stream; } else diff --git a/modules/packetizer/mpeg4video.c b/modules/packetizer/mpeg4video.c index 91970408d7..82bcd5d10b 100644 --- a/modules/packetizer/mpeg4video.c +++ b/modules/packetizer/mpeg4video.c @@ -31,14 +31,11 @@ # include "config.h" #endif -#include - #include #include #include #include #include -#include #include #include @@ -159,8 +156,7 @@ static int Open( vlc_object_t *p_this ) { /* We have a vol */ p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra; - p_dec->fmt_out.p_extra = malloc( p_dec->fmt_in.i_extra ); - assert( p_dec->fmt_out.p_extra ); + p_dec->fmt_out.p_extra = xmalloc( p_dec->fmt_in.i_extra ); memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra ); @@ -291,8 +287,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag ) if( (size_t)p_dec->fmt_out.i_extra != p_frag->i_buffer ) { p_dec->fmt_out.p_extra = - realloc_or_free( p_dec->fmt_out.p_extra, p_frag->i_buffer ); - assert( p_dec->fmt_out.p_extra ); + xrealloc( p_dec->fmt_out.p_extra, p_frag->i_buffer ); p_dec->fmt_out.i_extra = p_frag->i_buffer; } memcpy( p_dec->fmt_out.p_extra, p_frag->p_buffer, p_frag->i_buffer ); diff --git a/modules/packetizer/vc1.c b/modules/packetizer/vc1.c index 7cbc47dc6a..679ee15f0c 100644 --- a/modules/packetizer/vc1.c +++ b/modules/packetizer/vc1.c @@ -30,13 +30,10 @@ # include "config.h" #endif -#include - #include #include #include #include -#include #include #include @@ -141,7 +138,8 @@ static int Open( vlc_object_t *p_this ) /* Create the output format */ es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in ); p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) ); - assert( p_sys ); + if( unlikely( !p_sys ) ) + return VLC_ENOMEM; packetizer_Init( &p_sys->packetizer, p_vc1_startcode, sizeof(p_vc1_startcode), @@ -313,8 +311,7 @@ static void BuildExtraData( decoder_t *p_dec ) if( p_es->i_extra != i_extra ) { p_es->i_extra = i_extra; - p_es->p_extra = realloc_or_free( p_es->p_extra, p_es->i_extra ); - assert( p_es->p_extra ); + p_es->p_extra = xrealloc( p_es->p_extra, p_es->i_extra ); } memcpy( p_es->p_extra, p_sys->sh.p_sh->p_buffer, p_sys->sh.p_sh->i_buffer ); diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c index 60e45591bc..919c6d2722 100644 --- a/modules/services_discovery/sap.c +++ b/modules/services_discovery/sap.c @@ -414,7 +414,8 @@ static int OpenDemux( vlc_object_t *p_this ) if( p_sdp->psz_uri == NULL ) goto error; p_demux->p_sys = (demux_sys_t *)malloc( sizeof(demux_sys_t) ); - assert( p_demux->p_sys ); + if( unlikely( !p_demux->p_sys ) ) + goto error; p_demux->p_sys->p_sdp = p_sdp; p_demux->pf_control = Control; p_demux->pf_demux = Demux; diff --git a/modules/stream_out/bridge.c b/modules/stream_out/bridge.c index 127634c4c1..aec3854732 100644 --- a/modules/stream_out/bridge.c +++ b/modules/stream_out/bridge.c @@ -30,13 +30,10 @@ # include "config.h" #endif -#include - #include #include #include #include -#include /***************************************************************************** * Module descriptor @@ -198,7 +195,8 @@ static int OpenOut( vlc_object_t *p_this ) p_stream->p_cfg ); p_sys = malloc( sizeof( out_sout_stream_sys_t ) ); - assert( p_sys ); + if( unlikely( !p_sys ) ) + return VLC_ENOMEM; p_sys->b_inited = false; var_Create( p_this->p_libvlc, "bridge-lock", VLC_VAR_MUTEX ); @@ -261,8 +259,7 @@ static sout_stream_id_t * AddOut( sout_stream_t *p_stream, es_format_t *p_fmt ) p_bridge = var_GetAddress( p_stream->p_libvlc, p_sys->psz_name ); if ( p_bridge == NULL ) { - p_bridge = malloc( sizeof( bridge_t ) ); - assert( p_bridge ); + p_bridge = xmalloc( sizeof( bridge_t ) ); var_Create( p_stream->p_libvlc, p_sys->psz_name, VLC_VAR_ADDRESS ); var_SetAddress( p_stream->p_libvlc, p_sys->psz_name, p_bridge ); @@ -279,12 +276,10 @@ static sout_stream_id_t * AddOut( sout_stream_t *p_stream, es_format_t *p_fmt ) if ( i == p_bridge->i_es_num ) { - p_bridge->pp_es = realloc_or_free( p_bridge->pp_es, + p_bridge->pp_es = xrealloc( p_bridge->pp_es, (p_bridge->i_es_num + 1) * sizeof(bridged_es_t *) ); - assert( p_bridge->pp_es ); p_bridge->i_es_num++; - p_bridge->pp_es[i] = malloc( sizeof(bridged_es_t) ); - assert( p_bridge->pp_es[i] ); + p_bridge->pp_es[i] = xmalloc( sizeof(bridged_es_t) ); } p_sys->p_es = p_es = p_bridge->pp_es[i]; @@ -397,7 +392,8 @@ static int OpenIn( vlc_object_t *p_this ) vlc_value_t val; p_sys = malloc( sizeof( in_sout_stream_sys_t ) ); - assert( p_sys ); + if( unlikely( !p_sys ) ) + return VLC_ENOMEM; p_sys->p_out = sout_StreamNew( p_stream->p_sout, p_stream->psz_next ); if( !p_sys->p_out ) diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c index 78117fef73..0f161700e7 100644 --- a/modules/stream_out/mosaic_bridge.c +++ b/modules/stream_out/mosaic_bridge.c @@ -42,12 +42,8 @@ #include #include -#include - #include "../video_filter/mosaic.h" -#include - /***************************************************************************** * Local structures *****************************************************************************/ @@ -363,8 +359,7 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) vlc_object_t *p_libvlc = VLC_OBJECT( p_stream->p_libvlc ); vlc_value_t val; - p_bridge = malloc( sizeof( bridge_t ) ); - assert( p_bridge ); + p_bridge = xmalloc( sizeof( bridge_t ) ); var_Create( p_libvlc, "mosaic-struct", VLC_VAR_ADDRESS ); val.p_address = p_bridge; @@ -382,12 +377,10 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) if ( i == p_bridge->i_es_num ) { - p_bridge->pp_es = realloc_or_free( p_bridge->pp_es, + p_bridge->pp_es = xrealloc( p_bridge->pp_es, (p_bridge->i_es_num + 1) * sizeof(bridged_es_t *) ); - assert( p_bridge->pp_es ); p_bridge->i_es_num++; - p_bridge->pp_es[i] = malloc( sizeof(bridged_es_t) ); - assert( p_bridge->pp_es[i] ); + p_bridge->pp_es[i] = xmalloc( sizeof(bridged_es_t) ); } p_sys->p_es = p_es = p_bridge->pp_es[i]; diff --git a/modules/video_filter/audiobargraph_v.c b/modules/video_filter/audiobargraph_v.c index 2ca709a30a..0a14e822b1 100644 --- a/modules/video_filter/audiobargraph_v.c +++ b/modules/video_filter/audiobargraph_v.c @@ -28,7 +28,6 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include #include #include @@ -38,8 +37,6 @@ #include #include -#include - #ifdef LoadImage # undef LoadImage #endif @@ -942,9 +939,8 @@ void parse_i_values( BarGraph_t *p_BarGraph, char *i_values) res = strtok_r(i_values, delim, &tok); while (res != NULL) { p_BarGraph->nbChannels++; - p_BarGraph->i_values = realloc_or_free(p_BarGraph->i_values, + p_BarGraph->i_values = xrealloc(p_BarGraph->i_values, p_BarGraph->nbChannels*sizeof(int)); - assert(p_BarGraph->i_values); p_BarGraph->i_values[p_BarGraph->nbChannels-1] = __MAX( __MIN( atof(res)*p_BarGraph->scale, p_BarGraph->scale ), 0 ); res = strtok_r(NULL, delim, &tok); } diff --git a/modules/video_filter/bluescreen.c b/modules/video_filter/bluescreen.c index d889b540c9..a658c36a00 100644 --- a/modules/video_filter/bluescreen.c +++ b/modules/video_filter/bluescreen.c @@ -29,12 +29,9 @@ # include "config.h" #endif -#include - #include #include #include -#include #define BLUESCREEN_HELP N_( \ "This effect, also known as \"greenscreen\" or \"chroma key\" blends " \ @@ -188,9 +185,8 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) return NULL; } - p_sys->p_at = realloc_or_free( p_sys->p_at, - i_lines * i_pitch * sizeof( uint8_t ) ); - assert( p_sys->p_at ); + p_sys->p_at = xrealloc( p_sys->p_at, + i_lines * i_pitch * sizeof( uint8_t ) ); p_at = p_sys->p_at; vlc_mutex_lock( &p_sys->lock ); diff --git a/modules/video_filter/gaussianblur.c b/modules/video_filter/gaussianblur.c index 48dc7f96fe..995b9290c5 100644 --- a/modules/video_filter/gaussianblur.c +++ b/modules/video_filter/gaussianblur.c @@ -29,8 +29,6 @@ # include "config.h" #endif -#include - #include #include #include @@ -102,11 +100,9 @@ static void gaussianblur_InitDistribution( filter_sys_t *p_sys ) { double f_sigma = p_sys->f_sigma; int i_dim = (int)(3.*f_sigma); - type_t *pt_distribution = malloc( (2*i_dim+1) * sizeof( type_t ) ); + type_t *pt_distribution = xmalloc( (2*i_dim+1) * sizeof( type_t ) ); int x; - assert( pt_distribution ); - for( x = -i_dim; x <= i_dim; x++ ) { const float f_distribution = sqrt( exp(-(x*x)/(f_sigma*f_sigma) ) / (2.*M_PI*f_sigma*f_sigma) ); @@ -217,9 +213,8 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) const int i_pitch = p_pic->p[Y_PLANE].i_pitch; int i_col, i_line; - p_sys->pt_scale = malloc( i_visible_lines * i_pitch * sizeof( type_t ) ); + p_sys->pt_scale = xmalloc( i_visible_lines * i_pitch * sizeof( type_t ) ); pt_scale = p_sys->pt_scale; - assert( pt_scale ); for( i_line = 0 ; i_line < i_visible_lines ; i_line++ ) { diff --git a/modules/video_filter/mosaic.c b/modules/video_filter/mosaic.c index ea47c41eec..41b3a645f4 100644 --- a/modules/video_filter/mosaic.c +++ b/modules/video_filter/mosaic.c @@ -34,13 +34,10 @@ #include #include /* INT_MAX */ -#include #include #include -#include - #include "mosaic.h" #define BLANK_DELAY INT64_C(1000000) @@ -257,16 +254,14 @@ static void __mosaic_ParseSetOffsets( vlc_object_t *p_this, { i_index++; - p_sys->pi_x_offsets = realloc_or_free( p_sys->pi_x_offsets, + p_sys->pi_x_offsets = xrealloc( p_sys->pi_x_offsets, i_index * sizeof(int) ); - assert( p_sys->pi_x_offsets ); p_sys->pi_x_offsets[i_index - 1] = atoi( psz_offsets ); psz_end = strchr( psz_offsets, ',' ); psz_offsets = psz_end + 1; - p_sys->pi_y_offsets = realloc_or_free( p_sys->pi_y_offsets, + p_sys->pi_y_offsets = xrealloc( p_sys->pi_y_offsets, i_index * sizeof(int) ); - assert( p_sys->pi_y_offsets ); p_sys->pi_y_offsets[i_index - 1] = atoi( psz_offsets ); psz_end = strchr( psz_offsets, ',' ); psz_offsets = psz_end + 1; @@ -364,9 +359,8 @@ static int CreateFilter( vlc_object_t *p_this ) { psz_end = strchr( psz_order, ',' ); i_index++; - p_sys->ppsz_order = realloc_or_free( p_sys->ppsz_order, + p_sys->ppsz_order = xrealloc( p_sys->ppsz_order, i_index * sizeof(char *) ); - assert( p_sys->ppsz_order ); p_sys->ppsz_order[i_index - 1] = strndup( psz_order, psz_end - psz_order ); psz_order = psz_end+1; @@ -882,9 +876,8 @@ static int MosaicCallback( vlc_object_t *p_this, char const *psz_var, { psz_end = strchr( psz_order, ',' ); i_index++; - p_sys->ppsz_order = realloc_or_free( p_sys->ppsz_order, + p_sys->ppsz_order = xrealloc( p_sys->ppsz_order, i_index * sizeof(char *) ); - assert( p_sys->ppsz_order ); p_sys->ppsz_order[i_index - 1] = strndup( psz_order, psz_end - psz_order ); psz_order = psz_end+1; diff --git a/modules/video_filter/rss.c b/modules/video_filter/rss.c index b9a080b7af..36e34372f4 100644 --- a/modules/video_filter/rss.c +++ b/modules/video_filter/rss.c @@ -35,8 +35,6 @@ # include "config.h" #endif -#include - #include #include @@ -50,8 +48,6 @@ #include -#include - #include /***************************************************************************** @@ -710,9 +706,8 @@ static bool ParseFeed( filter_t *p_filter, xml_reader_t *p_xml_reader, { b_is_item = true; p_feed->i_items++; - p_feed->p_items = realloc_or_free( p_feed->p_items, + p_feed->p_items = xrealloc( p_feed->p_items, p_feed->i_items * sizeof( rss_item_t ) ); - assert( p_feed->p_items ); p_feed->p_items[p_feed->i_items-1].psz_title = NULL; p_feed->p_items[p_feed->i_items-1].psz_description = NULL; p_feed->p_items[p_feed->i_items-1].psz_link = NULL; diff --git a/modules/video_output/msw/directx.c b/modules/video_output/msw/directx.c index 10b401dbdf..c2c7fc11b7 100644 --- a/modules/video_output/msw/directx.c +++ b/modules/video_output/msw/directx.c @@ -38,13 +38,10 @@ # include "config.h" #endif -#include - #include #include #include #include /* needed for wallpaper */ -#include #include #include /* ListView_(Get|Set)* */ @@ -1820,12 +1817,10 @@ BOOL WINAPI DirectXEnumCallback2( GUID* p_guid, LPTSTR psz_desc, module_config_t *p_item = (module_config_t *)p_context; - p_item->ppsz_list = realloc_or_free( p_item->ppsz_list, + p_item->ppsz_list = xrealloc( p_item->ppsz_list, (p_item->i_list+2) * sizeof(char *) ); - assert( p_item->ppsz_list ); - p_item->ppsz_list_text = realloc_or_free( p_item->ppsz_list_text, + p_item->ppsz_list_text = xrealloc( p_item->ppsz_list_text, (p_item->i_list+2) * sizeof(char *) ); - assert( p_item->ppsz_list_text ); p_item->ppsz_list[p_item->i_list] = strdup( psz_drivername ); p_item->ppsz_list_text[p_item->i_list] = NULL; -- 2.39.2