#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_input.h>
#include <vlc_demux.h>
#include <vlc_dialog.h>
#include <vlc_charset.h>
+#include <vlc_memory.h>
#include "common.h"
#include "filter.h"
dshow_stream.p_device_filter = p_device_filter;
dshow_stream.p_capture_filter = p_capture_filter;
- p_sys->pp_streams = (dshow_stream_t **)realloc( p_sys->pp_streams,
+ p_sys->pp_streams = realloc_or_free( 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;
if( !list_devices.size() ) return VLC_SUCCESS;
- p_item->ppsz_list =
- (char **)realloc( p_item->ppsz_list,
+ p_item->ppsz_list = realloc_or_free( p_item->ppsz_list,
(list_devices.size()+3) * sizeof(char *) );
- p_item->ppsz_list_text =
- (char **)realloc( p_item->ppsz_list_text,
+ assert( p_item->ppsz_list );
+ p_item->ppsz_list_text = realloc_or_free( p_item->ppsz_list_text,
(list_devices.size()+3) * sizeof(char *) );
+ assert( p_item->ppsz_list_text );
list<string>::iterator iter;
for( iter = list_devices.begin(), i = 2; iter != list_devices.end();
if ( pi_size == NULL )
{
p_data = malloc( MAX_TPDU_SIZE );
+ assert( p_data );
}
for ( ; ; )
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);
ca_msg_t ca_msg;
int i_ret;
+ assert( p_apdu );
+
*p++ = (i_tag >> 16);
*p++ = (i_tag >> 8) & 0xff;
*p++ = i_tag & 0xff;
else
p_data = malloc( 6 );
+ assert( p_data );
+
p_data[0] = i_list_mgt;
p_data[1] = i_program_number >> 8;
p_data[2] = i_program_number & 0xff;
else
p_data = realloc( p_capmt, i_capmt_size + 5 );
+ assert( p_data );
+
i = i_capmt_size;
p_data[i] = i_type;
i_tag = AOT_ANSW;
i_size = 1 + strlen( p_object->u.answ.psz_answ );
p_data = malloc( i_size );
+ assert( p_data );
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;
i_tag = AOT_MENU_ANSW;
i_size = 1;
p_data = malloc( i_size );
+ assert( p_data );
p_data[0] = p_object->u.menu_answ.i_choice;
break;
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 );
strncpy( p_mmi->last_object.u.enq.psz_text, (char *)d, l );
p_mmi->last_object.u.enq.psz_text[l] = '\0';
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_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;
}
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 );
vlc_iconv( iconv_handle, &psz_stringstart, &i_in, &psz_tmp, &i_out );
vlc_iconv_close( iconv_handle );
*psz_tmp = '\0';
/* alloc an array to store all the matched ports */
p_sys->pp_jack_port_table = realloc( 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<i_out_ports;i++)
{
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
+#include <vlc_memory.h>
#include "asf.h"
#include "buffer.h"
{
p_buf->i_size = ( i_default_size > 0 ) ? i_default_size : 2048;
p_buf->i_data = 0;
- if( !( p_buf->p_data = malloc( p_buf->i_size ) ) )
- {
- return( -1 );
- }
- return( 0 );
+ p_buf->p_data = malloc( p_buf->i_size );
+ return p_buf->p_data ? 0 : -1;
}
int var_buffer_reinitwrite( var_buffer_t *p_buf, int i_default_size )
p_buf->i_size = ( i_default_size > 0 ) ? i_default_size : 2048;
p_buf->p_data = malloc( p_buf->i_size );
}
- if( !p_buf->p_data )
- {
- return( -1 );
- }
- return( 0 );
+ return p_buf->p_data ? 0 : -1;
}
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( p_buf->p_data, p_buf->i_size );
+ p_buf->p_data = realloc_or_free( p_buf->p_data, p_buf->i_size );
+ assert( p_buf->p_data );
}
p_buf->p_data[p_buf->i_data] = i_byte&0xff;
p_buf->i_data++;
if( p_buf->i_data + i_mem >= p_buf->i_size )
{
p_buf->i_size += i_mem + 1024;
- p_buf->p_data = realloc( p_buf->p_data, p_buf->i_size );
+ p_buf->p_data = realloc_or_free( p_buf->p_data, p_buf->i_size );
+ assert( p_buf->p_data );
}
- memcpy( p_buf->p_data + p_buf->i_data,
- p_mem,
- i_mem );
+ memcpy( p_buf->p_data + p_buf->i_data, p_mem, i_mem );
p_buf->i_data += i_mem;
}
char *psz_out, *psz_tmp;
psz_out = psz_tmp = malloc( i_out + 1 );
+ assert( psz_out );
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 );
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_access.h>
#include <vlc_strings.h>
#include <vlc_input.h>
+#include <vlc_memory.h>
#include <vlc_network.h>
#include <vlc_url.h>
if( ck.i_data > 0 )
{
p_sys->i_header += ck.i_data;
- p_sys->p_header = realloc( p_sys->p_header, p_sys->i_header );
+ p_sys->p_header = realloc_or_free( p_sys->p_header, p_sys->i_header );
+ assert( p_sys->p_header );
memcpy( &p_sys->p_header[p_sys->i_header - ck.i_data],
ck.p_data, ck.i_data );
}
{ \
int i; \
psz = malloc( size + 1); \
+ assert( psz ); \
for( i = 0; i < size; i++ ) \
{ \
psz[i] = p[i]; \
free( p_sys->p_cmd );
p_sys->i_cmd = i_data;
p_sys->p_cmd = malloc( i_data );
+ assert( p_sys->p_cmd );
memcpy( p_sys->p_cmd, p_data, i_data );
*pi_used = i_data; /* by default */
{
if( p_sys->p_header )
{
- p_sys->p_header = realloc( p_sys->p_header,
- p_sys->i_header + i_packet_length - 8 );
+ p_sys->p_header = realloc_or_free( 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;
else
{
uint8_t* p_packet = malloc( i_packet_length - 8 ); // don't bother with preheader
+ assert( p_packet );
memcpy( p_packet, p_data + 8, i_packet_length - 8 );
p_sys->p_header = p_packet;
p_sys->i_header = i_packet_length - 8;
else
{
uint8_t* p_packet = malloc( i_packet_length - 8 ); // don't bother with preheader
+ assert( p_packet );
memcpy( p_packet, p_data + 8, i_packet_length - 8 );
FREENULL( p_sys->p_media );
p_sys->p_media = p_packet;
#endif
#include <vlc_common.h>
+#include <vlc_memory.h>
#include "rtsp.h"
#include "real.h"
#define LE_32C(x,y) do {uint32_t in=y; *(uint32_t *)(x)=GetDWLE(&in);} while(0)
#define MAX(x,y) ((x>y) ? x : y)
-/* XXX find a better place for this */
-static inline void *realloc_(void *p, size_t sz)
-{
- void *n = realloc(p, sz);
- if( !n )
- free(p);
- return n;
-}
-
static void hash(char *field, char *param)
{
uint32_t a, b, c, d;
/* setup our streams */
real_calc_response_and_checksum (challenge2, checksum, challenge1);
- buf = realloc_(buf, strlen(challenge2) + strlen(checksum) + 32);
+ buf = realloc_or_free(buf, strlen(challenge2) + strlen(checksum) + 32);
if( !buf ) goto error;
sprintf(buf, "RealChallenge2: %s, sd=%s", challenge2, checksum);
rtsp_schedule_field(rtsp_session, buf);
- buf = realloc_(buf, strlen(session_id) + 32);
+ buf = realloc_or_free(buf, strlen(session_id) + 32);
if( !buf ) goto error;
sprintf(buf, "If-Match: %s", session_id);
rtsp_schedule_field(rtsp_session, buf);
rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play");
- buf = realloc_(buf, strlen(mrl) + 32);
+ buf = realloc_or_free(buf, strlen(mrl) + 32);
if( !buf ) goto error;
sprintf(buf, "%s/streamid=0", mrl);
rtsp_request_setup(rtsp_session,buf);
if (h->prop->num_streams > 1) {
rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play");
- buf = realloc_(buf, strlen(session_id) + 32);
+ buf = realloc_or_free(buf, strlen(session_id) + 32);
if( !buf ) goto error;
sprintf(buf, "If-Match: %s", session_id);
rtsp_schedule_field(rtsp_session, buf);
- buf = realloc_(buf, strlen(mrl) + 32);
+ buf = realloc_or_free(buf, strlen(mrl) + 32);
if( !buf ) goto error;
sprintf(buf, "%s/streamid=1", mrl);
rtsp_request_setup(rtsp_session,buf);
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_block.h>
-
-
#include <vlc_input.h>
#include <vlc_playlist.h>
+#include <vlc_memory.h>
#if 0 //def HAVE_AVAHI_CLIENT
#include "bonjour.h"
p_sys->i_header_size = 0;
p_sys->p_header = malloc( 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;
}
{
p_sys->i_header_allocated =
p_buffer->i_buffer + p_sys->i_header_size + 1024;
- p_sys->p_header =
- realloc( p_sys->p_header, p_sys->i_header_allocated );
+ p_sys->p_header = realloc_or_free( 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,
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_aout.h>
#include <vlc_filter.h>
+#include <vlc_memory.h>
+
/*****************************************************************************
* Local structures
*****************************************************************************/
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( p_filter->p_sys->p_buf,
- p_in_buf->i_buffer * 3 );
+ p_filter->p_sys->p_buf = realloc_or_free( 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;
}
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_aout.h>
#include <vlc_cpu.h>
+#include <vlc_memory.h>
+
/* ALSA part
Note: we use the new API which is available since 0.9.0beta10a. */
#define ALSA_PCM_NEW_HW_PARAMS_API
break;
}
- p_item->ppsz_list =
- (char **)realloc( p_item->ppsz_list,
+ p_item->ppsz_list = realloc_or_free( p_item->ppsz_list,
(p_item->i_list + 2) * sizeof(char *) );
- p_item->ppsz_list_text =
- (char **)realloc( p_item->ppsz_list_text,
+ assert( p_item->ppsz_list );
+ p_item->ppsz_list_text = realloc_or_free( 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++;
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_aout.h>
#include <vlc_charset.h>
+#include <vlc_memory.h>
#include <windows.h>
#include <mmsystem.h>
int wave_devices = waveOutGetNumDevs();
- p_item->ppsz_list =
- (char **)realloc( p_item->ppsz_list,
+ p_item->ppsz_list = realloc_or_free( p_item->ppsz_list,
(wave_devices+2) * sizeof(char *) );
- p_item->ppsz_list_text =
- (char **)realloc( p_item->ppsz_list_text,
+ assert( p_item->ppsz_list );
+ p_item->ppsz_list_text = realloc_or_free( p_item->ppsz_list_text,
(wave_devices+2) * sizeof(char *) );
+ assert( p_item->ppsz_list_text );
WAVEOUTCAPS caps;
char sz_dev_name[MAXPNAMELEN+32];
#include "xarray.h"
#ifdef HAVE_STDLIB_H
-# include <stdlib.h> /* realloc() */
+# include <stdlib.h> /* malloc() */
#endif
#undef HISTORY_DEBUG
#include <string.h>
#include "xarray.h"
+#include <vlc_memory.h>
+
/* local prototypes */
XArray * xarray_New (unsigned int);
#define XARRAY_GROW_ARRAY(xarray) \
{ \
- xarray->array = (void *) realloc (xarray->array, xarray->size * 2); \
+ xarray->array = realloc_or_free (xarray->array, xarray->size * 2); \
if (xarray->array == NULL) return XARRAY_ENOMEM; \
}
#endif
#include <stdio.h>
+#include <assert.h>
+
+#include <vlc_memory.h>
#include "xurl.h"
i_characters_until_last_slash = pc_last_slash - psz_path;
psz_path_head = malloc( i_characters_until_last_slash + 1 );
+ assert( psz_path_head );
strncpy( psz_path_head, psz_path, i_characters_until_last_slash + 1 );
/* terminate the resulting string with '\0' */
size_t i_new_string_length = strlen( psz_string ) +
strlen( psz_to_append ) + 1;
- psz_string = (char *) realloc( psz_string, i_new_string_length );
+ psz_string = realloc_or_free( psz_string, i_new_string_length );
+ assert( psz_string );
return strcat( psz_string, psz_to_append );
}
#include <vlc_plugin.h>
#include <vlc_codec.h>
#include <vlc_sout.h>
+#include <vlc_memory.h>
#include <vlc_bits.h>
}
p_region->p_pixbuf = malloc( i_height * i_width );
+ assert( p_region->p_pixbuf );
p_region->i_depth = 0;
b_fill = true;
}
/* We create a new object */
p_region->i_object_defs++;
- p_region->p_object_defs =
- realloc( p_region->p_object_defs,
+ p_region->p_object_defs = realloc_or_free( 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];
if( p_region->p_object_defs[i].i_id != i_id ) continue;
p_region->p_object_defs[i].psz_text =
- realloc( p_region->p_object_defs[i].psz_text,
+ realloc_or_free( 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++ )
#ifndef RANDOM_DITHERING
pi_delta = malloc( ( 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;
{
encoder_region_t region;
region.i_width = region.i_height = 0;
- p_sys->p_regions =
- realloc( p_sys->p_regions, sizeof(encoder_region_t) *
- (p_sys->i_regions + 1) );
+ p_sys->p_regions = realloc_or_free( 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;
}
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
#include <vlc_aout.h>
+#include <vlc_memory.h>
#ifdef HAVE_FLAC_STREAM_DECODER_H
# include <FLAC/stream_decoder.h>
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( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+ p_dec->fmt_out.p_extra = realloc_or_free( 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 );
}
if( p_sys->i_buffer < p_aout_buf->i_buffer * 2 )
{
p_sys->p_buffer =
- realloc( p_sys->p_buffer, p_aout_buf->i_buffer * 2 );
+ realloc_or_free( p_sys->p_buffer, p_aout_buf->i_buffer * 2 );
+ assert( p_sys->p_buffer );
p_sys->i_buffer = p_aout_buf->i_buffer * 2;
}
/* 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 );
memcpy( p_enc->fmt_out.p_extra, "fLaC", 4 );
memcpy( ((uint8_t *)p_enc->fmt_out.p_extra) + 4, buffer,
STREAMINFO_SIZE );
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_input.h>
#include <vlc_codec.h>
#include <vlc_osd.h>
+#include <vlc_memory.h>
#include <kate/kate.h>
#ifdef HAVE_TIGER
/* Backup headers as extra data */
uint8_t *p_extra;
- p_dec->fmt_in.p_extra =
- realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra + kp.nbytes + 2 );
+ p_dec->fmt_in.p_extra = realloc_or_free( 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;
else
{
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra =
- realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+ p_dec->fmt_out.p_extra = realloc_or_free( 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 );
}
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_aout.h>
#include <vlc_codec.h>
+#include <vlc_memory.h>
#if !defined (__APPLE__) && !defined(WIN32)
# define LOADER 1
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( p_sys->p_buffer, p_sys->i_buffer_size );
+ p_sys->p_buffer = realloc_or_free( p_sys->p_buffer, p_sys->i_buffer_size );
+ assert( p_sys->p_buffer );
}
memcpy( &p_sys->p_buffer[p_sys->i_buffer], p_block->p_buffer,
p_block->i_buffer );
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
int i_vide = p_dec->fmt_in.i_extra;
unsigned int *p_vide = p_dec->fmt_in.p_extra;
- decoder_sys_t *p_sys = malloc( sizeof( decoder_sys_t ) );
- memset(p_sys,0,sizeof( decoder_sys_t ) );
+ decoder_sys_t *p_sys = calloc( 1, sizeof( decoder_sys_t ) );
+ assert( p_sys );
if( i_vide < 8 )
{
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_input.h>
#include <vlc_codec.h>
#include <vlc_aout.h>
+#include <vlc_memory.h>
#include <ogg/ogg.h>
#include <speex/speex.h>
{
uint8_t *p_extra;
- p_dec->fmt_in.p_extra =
- realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra +
- oggpacket.bytes + 2 );
+ p_dec->fmt_in.p_extra = realloc_or_free( 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;
if( p_sys->b_packetizer )
{
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra =
- realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+ p_dec->fmt_out.p_extra = realloc_or_free( 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 );
}
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 );
speex_bits_read_from( &p_sys->bits, (char*)p_oggpacket->packet,
p_oggpacket->bytes);
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 );
/* Create and store headers */
pp_header[0] = speex_header_to_packet( &p_sys->header, &pi_header[0] );
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 );
for( i = 0; i < 2; i++ )
{
*(p_extra++) = pi_header[i] >> 8;
# include "config.h"
#endif
+#include <assert.h>
+
#include "subsdec.h"
#include <vlc_plugin.h>
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 );
psz_subtitle = realloc( psz_new_subtitle,
psz_convert_buffer_out - psz_new_subtitle );
+ if( !psz_subtitle )
+ psz_subtitle = psz_new_subtitle;
}
}
psz_subtitle++;
}
*psz_text = '\0';
- psz_text_start = realloc( psz_text_start, strlen( psz_text_start ) + 1 );
+ char *psz = realloc( psz_text_start, strlen( psz_text_start ) + 1 );
+ if( psz ) psz_text_start = psz;
return psz_text_start;
}
psz_subtitle++;
}
*psz_text = '\0';
- psz_text_start = realloc( psz_text_start, strlen( psz_text_start ) + 1 );
+
+ char *psz = realloc( psz_text_start, strlen( psz_text_start ) + 1 );
+ if( psz ) psz_text_start = psz;
return psz_text_start;
}
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
#include <vlc_sout.h>
#include <vlc_input.h>
+#include <vlc_memory.h>
#include <ogg/ogg.h>
#include <theora/theora.h>
/* Backup headers as extra data */
uint8_t *p_extra;
- p_dec->fmt_in.p_extra =
- realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra +
- oggpacket.bytes + 2 );
+ p_dec->fmt_in.p_extra = realloc_or_free( 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;
else
{
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra =
- realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+ p_dec->fmt_out.p_extra = realloc_or_free( 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 );
}
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( p_enc->fmt_out.p_extra,
- p_enc->fmt_out.i_extra + header.bytes );
+ p_enc->fmt_out.p_extra = realloc_or_free( 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;
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
#include <vlc_aout.h>
#include <vlc_input.h>
#include <vlc_sout.h>
+#include <vlc_memory.h>
#include <ogg/ogg.h>
/* Backup headers as extra data */
uint8_t *p_extra;
- p_dec->fmt_in.p_extra =
- realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra +
- oggpacket.bytes + 2 );
+ p_dec->fmt_in.p_extra = realloc_or_free( 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;
else
{
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra =
- realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+ p_dec->fmt_out.p_extra = realloc_or_free( 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 );
}
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 );
for( i = 0; i < 3; i++ )
{
*(p_extra++) = header[i].bytes >> 8;
# include "config.h"
#endif
+#include <assert.h>
+
#include "http.h"
#include "macros.h"
#include <vlc_url.h>
+#include <vlc_memory.h>
static int MacroParse( macro_t *m, char *psz_src )
{
{ \
int __i__ = *pp_dst - *pp_data; \
*pi_data += (l); \
- *pp_data = realloc( *pp_data, *pi_data ); \
+ *pp_data = realloc_or_free( *pp_data, *pi_data ); \
+ assert( *pp_data ); \
*pp_dst = (*pp_data) + __i__; \
}
#define PRINT( str ) \
if( !*item ) continue;
int i_item = atoi( item );
- p_items = realloc( p_items, (i_nb_items + 1) *
- sizeof(*p_items) );
+ p_items = realloc_or_free( p_items,
+ (i_nb_items + 1) * sizeof(*p_items) );
+ assert( p_items );
p_items[i_nb_items] = i_item;
i_nb_items++;
}
if( !*item ) continue;
int i_item = atoi( item );
- p_items = realloc( p_items, (i_nb_items + 1) *
- sizeof(*p_items) );
+ p_items = realloc_or_free( p_items,
+ (i_nb_items + 1) * sizeof(*p_items) );
+ assert( p_items );
p_items[i_nb_items] = i_item;
i_nb_items++;
}
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 );
src = dup = malloc( _end - _src + 1 );
end = src +( _end - _src );
+ assert( src );
+
memcpy( src, _src, _end - _src );
*end = '\0';
int i_index = dst - *pp_data;
*pi_data += i_copy;
- *pp_data = realloc( *pp_data, *pi_data );
+ *pp_data = realloc_or_free( *pp_data, *pi_data );
+ assert( *pp_data );
dst = (*pp_data) + i_index;
memcpy( dst, src, i_copy );
#include <assert.h>
+#include <vlc_memory.h>
+
/* Utility function for scandir */
static int Filter( const char *foo )
{
v->i_field = 0;
v->field = malloc( sizeof( mvar_t * ) );
+ assert( v->field );
v->field[0] = NULL;
return v;
void mvar_AppendVar( mvar_t *v, mvar_t *f )
{
- v->field = realloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+ v->field = realloc_or_free( v->field,
+ sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+ assert( v->field );
v->field[v->i_field] = f;
v->i_field++;
}
void mvar_PushVar( mvar_t *v, mvar_t *f )
{
- v->field = realloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+ v->field = realloc_or_free( v->field,
+ sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+ assert( v->field );
if( v->i_field > 0 )
{
memmove( &v->field[1], &v->field[0], sizeof( mvar_t * ) * v->i_field );
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include "http.h"
#include <vlc_strings.h>
+#include <vlc_memory.h>
/****************************************************************************
* File and directory functions
/* just load the file */
*pi_data = 0;
*pp_data = malloc( 1025 ); /* +1 for \0 */
+ assert( *pp_data );
+
while( ( i_read = fread( &(*pp_data)[*pi_data], 1, 1024, f ) ) == 1024 )
{
*pi_data += 1024;
- *pp_data = realloc( *pp_data, *pi_data + 1025 );
+ *pp_data = realloc_or_free( *pp_data, *pi_data + 1025 );
+ assert( *pp_data );
}
if( i_read > 0 )
{
f = malloc( sizeof( httpd_file_sys_t ) );
f->b_handler = false;
}
+ assert( f );
f->p_intf = p_intf;
f->p_file = NULL;
int i_len = strlen(psz_src);
psz_dir = malloc( i_len + 2 );
+ assert( psz_dir );
strcpy( psz_dir, psz_src );
/* Add a trailing sep to ease the .. step */
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
+#include <vlc_memory.h>
#include <errno.h> /* ENOMEM */
#include <ctype.h>
else if( *psz_item )
{
i_options++;
- ppsz_options = realloc( ppsz_options, i_options * sizeof(char *) );
+ ppsz_options = realloc_or_free( ppsz_options,
+ i_options * sizeof(char *) );
+ assert( ppsz_options );
ppsz_options[i_options - 1] = &psz_item[1];
}
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_interface.h>
#include <vlc_input.h>
+#include <vlc_memory.h>
#include <stdbool.h>
#include <sys/stat.h>
i_message += strlen( message->psz_name ) + i_level * sizeof( " " ) + 1;
psz_message = malloc( i_message );
+ assert( psz_message );
*psz_message = 0;
for( i = 0; i < i_level; i++ ) strcat( psz_message, " " );
strcat( psz_message, message->psz_name );
{
i_message += sizeof( " : " ) + strlen( message->psz_value ) +
sizeof( STRING_CR );
- psz_message = realloc( psz_message, i_message );
+ psz_message = realloc_or_free( psz_message, i_message );
+ assert( psz_message );
strcat( psz_message, " : " );
strcat( psz_message, message->psz_value );
strcat( psz_message, STRING_CR );
else
{
i_message += sizeof( STRING_CR );
- psz_message = realloc( psz_message, i_message );
+ psz_message = realloc_or_free( psz_message, i_message );
+ assert( psz_message );
strcat( psz_message, STRING_CR );
}
MessageToString( message->child[i], i_level + 1 );
i_message += strlen( child_message );
- psz_message = realloc( psz_message, i_message );
+ psz_message = realloc_or_free( psz_message, i_message );
+ assert( psz_message );
strcat( psz_message, child_message );
free( child_message );
}
#include <vlc_common.h>
#include <vlc_input.h>
#include <vlc_demux.h>
+#include <vlc_memory.h>
#include <limits.h>
#include <string.h>
+#include <assert.h>
#include "asademux.h"
#define MAXGROUP 24 /**< maximum number of regex match groups */
#define xmalloc malloc
-#define xrealloc realloc
+#define xrealloc realloc_or_free
#define xfree free
#define xstrdup strdup
if (state->selstr)
xfree(state->selstr);
state->selstr = xstrdup(state->matches[insn->v.select]);
+ assert(state->selstr);
state->sellen = strlen(state->selstr);
return 0;
}
newstr_size = v[0] * 2;
newstr = (char *)xmalloc(newstr_size);
+ assert(newstr);
memcpy(newstr, state->selstr, v[0]);
newpos = v[0];
if (need > avail) {
newstr_size += need - avail + 256;
newstr = (char *)xrealloc(newstr, newstr_size);
+ assert(newstr);
}
memcpy(newstr + newpos, src, need);
newpos += need;
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;
if (state->selstr)
xfree(state->selstr);
state->selstr = xstrdup(state->matches[0]);
+ assert(state->selstr);
state->sellen = strlen(state->selstr);
}
{
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';
#include <vlc_meta.h>
#include <vlc_codecs.h>
#include <vlc_charset.h>
+#include <vlc_memory.h>
#include "libavi.h"
if( tk->i_idxnb >= tk->i_idxmax )
{
tk->i_idxmax += 16384;
- tk->p_index = realloc( tk->p_index,
- tk->i_idxmax * sizeof( avi_entry_t ) );
+ tk->p_index = realloc_or_free( tk->p_index,
+ tk->i_idxmax * sizeof( avi_entry_t ) );
if( tk->p_index == NULL )
{
return;
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);
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);
p_sys->i_data = stream_Read( p_demux->s, p_sys->p_data, p_sys->i_data );
if( p_sys->i_data <= 0 )
{
*pi_int = p_sys->i_tracks;
*ppp_title = (input_title_t**)malloc( sizeof( input_title_t**) * p_sys->i_tracks );
+ assert( *ppp_sitle );
for( int i = 0; i < p_sys->i_tracks; i++ )
{
out_size = i_size * 2;
out_buffer = (uint8_t*)malloc(out_size);
+ assert(out_buffer);
z_str.next_in = (unsigned char*)p_buffer;
z_str.avail_in = i_size;
case Z_BUF_ERROR:
offset = z_str.next_out - out_buffer;
out_size *= 2;
- out_buffer = (uint8_t *)realloc(out_buffer, out_size);
+ out_buffer = (uint8_t *)realloc_or_free(out_buffer, out_size);
+ assert(out_buffer);
z_str.next_out = out_buffer + offset;
z_str.avail_out = out_size - offset;
break;
inflateEnd(&z_str);
- out_buffer = (uint8_t *)realloc(out_buffer, *pi_osize);
+ out_buffer = (uint8_t *)realloc_or_free(out_buffer, *pi_osize);
+ assert(out_buffer);
(*pp_obuffer) = out_buffer;
}
#endif
#include <vlc_dialog.h>
#include <vlc_url.h>
#include <vlc_strings.h>
+#include <vlc_memory.h>
#include <iostream>
#include <limits.h>
}
i_sdp_max += 1000;
- p_sdp = (uint8_t*)realloc( p_sdp, i_sdp_max );
+ p_sdp = (uint8_t*)realloc_or_free( p_sdp, i_sdp_max );
+ assert( p_sdp );
}
p_sys->p_sdp = (char*)p_sdp;
}
{
tk->fmt.i_extra = i_extra;
tk->fmt.p_extra = malloc( i_extra );
+ assert( tk->fmt.p_extra );
memcpy( tk->fmt.p_extra, p_extra, i_extra );
delete[] p_extra;
}
{
tk->fmt.i_extra = i_extra;
tk->fmt.p_extra = malloc( i_extra );
+ assert( tk->fmt.p_extra );
memcpy( tk->fmt.p_extra, p_extra, i_extra );
delete[] p_extra;
}
{
tk->fmt.i_extra = i_extra;
tk->fmt.p_extra = malloc( i_extra );
+ assert( tk->fmt.p_extra );
memcpy( tk->fmt.p_extra, p_extra, i_extra );
delete[] p_extra;
{
tk->fmt.i_extra = i_extra;
tk->fmt.p_extra = malloc( i_extra );
+ assert( tk->fmt.p_extra );
memcpy( tk->fmt.p_extra, p_extra, i_extra );
delete[] p_extra;
}
if( tk->p_es || tk->b_quicktime || tk->b_muxed || tk->b_asf )
{
/* Append */
- p_sys->track = (live_track_t**)realloc( p_sys->track, sizeof( live_track_t ) * ( p_sys->i_track + 1 ) );
+ p_sys->track = (live_track_t**)realloc_or_free( 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
{
tk->fmt.i_extra = atomLength-8;
tk->fmt.p_extra = malloc( tk->fmt.i_extra );
+ assert( tk->fmt.p_extra );
memcpy(tk->fmt.p_extra, pos+8, atomLength-8);
break;
}
{
tk->fmt.i_extra = qtState.sdAtomSize - 16;
tk->fmt.p_extra = malloc( tk->fmt.i_extra );
+ assert( tk->fmt.p_extra );
memcpy( tk->fmt.p_extra, &sdAtom[12], tk->fmt.i_extra );
}
}
#include "chapter_command.hpp"
+#include <assert.h>
+#include <vlc_memory.h>
+
chapter_item_c::~chapter_item_c()
{
std::vector<chapter_codec_cmds_c*>::iterator index = codecs.begin();
// 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( title.seekpoint, title.i_seekpoint * sizeof( seekpoint_t* ) );
+ title.seekpoint = realloc_or_free( title.seekpoint,
+ title.i_seekpoint * sizeof( seekpoint_t* ) );
+ assert( title.seekpoint );
title.seekpoint[title.i_seekpoint-1] = sk;
if ( b_user_display )
#include "demux.hpp"
+#include <assert.h>
+#include <vlc_memory.h>
+
extern "C" {
#include "../vobsub.h"
}
if( i_index >= i_index_max )
{
i_index_max += 1024;
- p_indexes = (mkv_index_t*)realloc( p_indexes, sizeof( mkv_index_t ) * i_index_max );
+ p_indexes = realloc_or_free( p_indexes,
+ sizeof( mkv_index_t ) * i_index_max );
+ assert( p_indexes );
}
#undef idx
}
if( i_index >= i_index_max )
{
i_index_max += 1024;
- p_indexes = (mkv_index_t*)realloc( p_indexes, sizeof( mkv_index_t ) * i_index_max );
+ p_indexes = realloc_or_free( p_indexes,
+ sizeof( mkv_index_t ) * i_index_max );
+ assert( p_indexes );
}
#undef idx
}
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 );
memcpy( tracks[i_track]->fmt.p_extra, &p_bih[1], tracks[i_track]->fmt.i_extra );
}
}
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 );
uint8_t *p_out = (uint8_t*)tracks[i_track]->fmt.p_extra;
*p_out++ = (i_size1>>8) & 0xFF;
*p_out++ = i_size1 & 0xFF;
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 );
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 );
stream_t *p_mp4_stream = stream_MemoryNew( VLC_OBJECT(&sys.demuxer),
tracks[i_track]->p_extra_data,
tracks[i_track]->i_extra_data,
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 );
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 );
}
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 );
memcpy( tracks[i_track]->fmt.p_extra, &p_wf[1], tracks[i_track]->fmt.i_extra );
}
}
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 );
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" ) )
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 );
p_extra = (uint8_t *)tracks[i_track]->fmt.p_extra; i_extra = 0;
for( i = 0; i < 3; i++ )
{
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 );
((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)
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 );
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 );
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" ) )
if( p_fmt->i_extra > 0 )
{
p_fmt->p_extra = malloc( p_tk->i_extra_data );
- if( !p_fmt->p_extra )
- abort();
+ assert( p_fmt->p_extra );
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 );
- if( !p_fmt->p_extra )
- abort();
+ assert( p_fmt->p_extra );
uint8_t *p_extra = (uint8_t*)p_fmt->p_extra;
memcpy( &p_extra[ 0], "TTA1", 4 );
SetWLE( &p_extra[ 4], 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 );
p_extra = (uint8_t *)tracks[i_track]->fmt.p_extra;
i_extra = 0;
{
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 );
memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, 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 );
memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
}
}
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_demux.h>
+#include <vlc_memory.h>
/* TODO:
* - test
else
{
p_idx->i_idx_max += 1000;
- p_idx->idx = realloc( p_idx->idx,
- p_idx->i_idx_max*sizeof(demux_index_entry_t));
+ p_idx->idx = realloc_or_free( p_idx->idx,
+ p_idx->i_idx_max*sizeof(demux_index_entry_t));
+ assert( p_idx->idx );
}
}
p_stream->p_headers =
realloc( p_sav = p_stream->p_headers, p_stream->i_headers +
p_oggpacket->bytes + (b_store_size ? 2 : 0) + (b_store_num_headers ? 1 : 0) );
- if( p_stream->p_headers )
+ if( !p_stream->p_headers )
+ p_stream->p_headers = p_sav;
+ else
{
uint8_t *p_extra = p_stream->p_headers + p_stream->i_headers;
p_ogg->i_bos--;
}
}
- else
- {
- p_stream->p_headers = p_sav;
- }
b_selected = false; /* Discard the header packet */
}
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_demux.h>
#include <vlc_charset.h>
#include "playlist.h"
#include <vlc_meta.h>
+#include <vlc_memory.h>
struct demux_sys_t
{
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 );
/* load the complete file */
for( ;; )
i_pos += i_read;
p_sys->i_data_len <<= 1 ;
- p_sys->psz_data = realloc( p_sys->psz_data, p_sys->i_data_len * sizeof( char * ) + 1 );
+ p_sys->psz_data = realloc_or_free( 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;
}
if( i_strlen < 1 ) continue;
msg_Dbg( p_demux, "param name strlen: %d", i_strlen);
psz_string = malloc( i_strlen + 1);
+ assert( psz_string );
memcpy( psz_string, psz_backup, i_strlen );
psz_string[i_strlen] = '\0';
msg_Dbg( p_demux, "param name: %s", psz_string);
if( i_strlen < 1 ) continue;
msg_Dbg( p_demux, "param value strlen: %d", i_strlen);
psz_string = malloc( i_strlen +1);
+ assert( psz_string );
memcpy( psz_string, psz_backup, i_strlen );
psz_string[i_strlen] = '\0';
msg_Dbg( p_demux, "param value: %s", psz_string);
i_strlen = psz_parse-psz_backup;
if( i_strlen < 1 ) continue;
psz_string = malloc( i_strlen +1);
+ assert( psz_string );
memcpy( psz_string, psz_backup, i_strlen );
psz_string[i_strlen] = '\0';
input_item_t *p_input;
free( psz_href );
psz_href = malloc( i_strlen +1);
+ assert( psz_string );
memcpy( psz_href, psz_backup, i_strlen );
psz_href[i_strlen] = '\0';
psz_tmp = psz_href + (i_strlen-1);
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#include <vlc_demux.h>
#include <assert.h>
+#include <vlc_demux.h>
+#include <vlc_memory.h>
/* 256-0xC0 for normal stream, 256 for 0xbd stream, 256 for 0xfd stream, 8 for 0xa0 AOB stream */
#define PS_TK_COUNT (256+256+256+8 - 0xc0)
}
}
- tmp_es = realloc( p_psm->es, sizeof(ps_es_t *) * (p_psm->i_es+1) );
+ tmp_es = realloc_or_free( p_psm->es, sizeof(ps_es_t *) * (p_psm->i_es+1) );
if( tmp_es )
{
p_psm->es = tmp_es;
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_input.h>
+#include <vlc_memory.h>
#include <errno.h>
#ifdef HAVE_SYS_TYPES_H
if( p_sys->i_subtitles >= i_max )
{
i_max += 500;
- if( !( p_sys->subtitle = realloc( p_sys->subtitle,
+ if( !( p_sys->subtitle = realloc_or_free( p_sys->subtitle,
sizeof(subtitle_t) * i_max ) ) )
{
- free( p_sys->subtitle );
TextUnload( &p_sys->txt );
free( p_sys );
return VLC_ENOMEM;
txt->i_line_count = 0;
txt->i_line = 0;
txt->line = calloc( i_line_max, sizeof( char * ) );
+ if( !txt->line )
+ return VLC_ENOMEM;
/* load the complete file */
for( ;; )
if( txt->i_line_count >= i_line_max )
{
i_line_max += 100;
- txt->line = realloc( txt->line, i_line_max * sizeof( char * ) );
+ txt->line = realloc_or_free( txt->line, i_line_max * sizeof( char * ) );
+ if( !txt->line )
+ return VLC_ENOMEM;
}
+ free( psz );
}
if( txt->i_line_count <= 0 )
}
i_old = strlen( psz_text );
- psz_text = realloc( psz_text, i_old + i_len + 1 + 1 );
+ psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
if( !psz_text )
{
return VLC_ENOMEM;
if( !p_sys->psz_header )
return VLC_ENOMEM;
- p_sys->psz_header =
- realloc( p_sys->psz_header,
- strlen( p_sys->psz_header ) + strlen( s ) + 2 );
+ 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" );
}
}
i_old = strlen( psz_text );
- psz_text = realloc( psz_text, i_old + i_len + 1 + 1 );
+ psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
if( !psz_text )
return VLC_ENOMEM;
strcat( psz_text, s );
else
{
i_old = strlen( psz_text ) + 1;
- psz_text = realloc( psz_text, i_old + strlen( s ) + 1 );
+ psz_text = realloc_or_free( psz_text, i_old + strlen( s ) + 1 );
if( !psz_text )
return VLC_ENOMEM;
strcat( psz_text, s );
int i_old = strlen( psz_text );
- psz_text = realloc( psz_text, i_old + i_len + 1 + 1 );
+ psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
if( !psz_text )
return VLC_ENOMEM;
int i_old = strlen( psz_text );
- psz_text = realloc( psz_text, i_old + i_len + 1 );
+ psz_text = realloc_or_free( psz_text, i_old + i_len + 1 );
if( !psz_text )
return VLC_ENOMEM;
/* 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 )*/
}
int i_old = strlen( psz_text );
- psz_text = realloc( psz_text, i_old + i_len + 1 + 1 );
+ psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
if( !psz_text )
return VLC_ENOMEM;
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_input.h>
+#include <vlc_memory.h>
#include <errno.h>
if( p_sys->i_subtitles >= p_sys->i_subs_alloc )
{
p_sys->i_subs_alloc += 500;
- if( !( p_sys->subtitle = realloc( p_sys->subtitle, sizeof(subtitle_t)
- * p_sys->i_subs_alloc ) ) )
+ if( !( p_sys->subtitle = realloc_or_free( p_sys->subtitle,
+ sizeof(subtitle_t) * p_sys->i_subs_alloc ) ) )
{
return VLC_ENOMEM;
}
#include <vlc_common.h>
#include <vlc_plugin.h>
+#include <vlc_memory.h>
#include <ctype.h>
#include <assert.h>
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(
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 );
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 );
{
msg_Dbg( p_demux, " - text='%s'", psz_text );
- psz_extra = realloc( psz_extra, strlen(psz_extra) + strlen(psz_text) + 1 );
+ psz_extra = realloc_or_free( psz_extra,
+ strlen(psz_extra) + strlen(psz_text) + 1 );
+ assert( psz_extra );
strcat( psz_extra, psz_text );
free( psz_text );
}
{
msg_Dbg( p_demux, " - desc='%s' item='%s'", psz_dsc, psz_itm );
#if 0
- psz_extra = realloc( psz_extra, strlen(psz_extra) + strlen(psz_dsc) + strlen(psz_itm) + 3 + 1 );
+ psz_extra = realloc_or_free( 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, " " );
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
+#include <vlc_memory.h>
#include <errno.h>
#include <sys/types.h>
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+ assert( p_sys );
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->i_original_frame_width = -1;
p_sys->i_original_frame_height = -1;
p_sys->b_palette = false;
language, &i_track_id ) == 2 )
{
p_sys->i_tracks++;
- p_sys->track = realloc( p_sys->track, sizeof( vobsub_track_t ) * (p_sys->i_tracks + 1 ) );
+ p_sys->track = realloc_or_free( p_sys->track,
+ sizeof( vobsub_track_t ) * (p_sys->i_tracks + 1 ) );
+ assert( p_sys->track );
language[2] = '\0';
/* Init the track */
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->i_track_id = i_track_id;
current_tk->i_delay = (int64_t)0;
i_location = loc;
current_tk->i_subtitles++;
- current_tk->p_subtitles = realloc( current_tk->p_subtitles, sizeof( subtitle_t ) * (current_tk->i_subtitles + 1 ) );
+ current_tk->p_subtitles =
+ realloc_or_free( 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;
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_vout.h>
+#include <vlc_memory.h>
/*****************************************************************************
* vout_sys_t: video output QNX method descriptor
if( i_ev == Ph_RESIZE_MSG )
{
- PhEvent_t *buf;
-
i_buflen = PhGetMsgSize( p_event );
- buf = realloc( p_event, i_buflen );
- if( buf == NULL )
- {
- free( p_event );
+ p_event = realloc_or_free( p_event, i_buflen );
+ if( p_event == NULL )
return( 1 );
- }
- p_event = buf;
}
else if( i_ev == Ph_EVENT_MSG )
{
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_osd.h>
#include <vlc_input.h>
#include <vlc_strings.h>
#include <vlc_dialog.h>
+#include <vlc_memory.h>
#include <math.h>
#include <errno.h>
* 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 )
{
(*pi_runs)++;
+ /* XXX this logic looks somewhat broken */
+
if( *ppp_styles )
{
- *ppp_styles = (ft_style_t **)
- realloc( *ppp_styles, *pi_runs * sizeof( ft_style_t * ) );
+ *ppp_styles = realloc_or_free( *ppp_styles,
+ *pi_runs * sizeof( ft_style_t * ) );
}
else if( *pi_runs == 1 )
{
- *ppp_styles = (ft_style_t **)
- malloc( *pi_runs * sizeof( ft_style_t * ) );
+ *ppp_styles = malloc( *pi_runs * sizeof( ft_style_t * ) );
}
/* We have just malloc'ed this memory successfully -
p_style = NULL;
}
+ /* XXX more iffy logic */
+
if( *ppi_run_lengths )
{
- *ppi_run_lengths = (uint32_t *)
- realloc( *ppi_run_lengths, *pi_runs * sizeof( uint32_t ) );
+ *ppi_run_lengths = realloc_or_free( *ppi_run_lengths,
+ *pi_runs * sizeof( uint32_t ) );
}
else if( *pi_runs == 1 )
{
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#include <vlc_memory.h>
+
typedef struct font_stack_t font_stack_t;
struct font_stack_t
{
if( *ppi_k_durations )
{
- *ppi_k_durations = (uint32_t *)
- realloc( *ppi_k_durations,
+ *ppi_k_durations = realloc_or_free( *ppi_k_durations,
*pi_k_runs * sizeof( uint32_t ) );
}
else if( *pi_k_runs == 1 )
if( *ppi_k_run_lengths )
{
- *ppi_k_run_lengths = (uint32_t *)
- realloc( *ppi_k_run_lengths,
+ *ppi_k_run_lengths = realloc_or_free( *ppi_k_run_lengths,
*pi_k_runs * sizeof( uint32_t ) );
}
else if( *pi_k_runs == 1 )
#include <vlc_xml.h>
#include <vlc_block.h>
#include <vlc_stream.h>
+#include <vlc_memory.h>
#include <ctype.h>
#include <stdarg.h>
static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *s )
{
xml_reader_t *p_reader;
- char *p_buffer, *p_new;
+ char *p_buffer;
int i_size, i_pos = 0, i_buffer = 2048;
XTag *p_root;
{
i_pos += i_size;
i_buffer += i_size;
- p_new = realloc( p_buffer, i_buffer );
- if( !p_new )
- {
- free( p_buffer );
+ p_buffer = realloc_or_free( p_buffer, i_buffer );
+ if( !p_buffer )
return NULL;
- }
- p_buffer = p_new;
}
if( i_pos + i_size == 0 )
{
XList *l, *last;
l = (XList *)malloc( sizeof(XList) );
+ assert( l );
l->prev = l->next = NULL;
l->data = data;
if( xi > 0 && xtag_cin (s[xi], good_end) )
{
ret = malloc( xi+1 );
+ assert( ret );
strncpy( ret, s, xi );
ret[xi] = '\0';
parser->start = &s[xi];
}
ret = malloc( xi+1 );
+ assert( ret );
strncpy( ret, s, xi );
ret[xi] = '\0';
parser->start = &s[xi];
}
attr = malloc( sizeof (*attr) );
+ assert( attr );
attr->name = name;
attr->value = value;
return attr;
if( (pcdata = xtag_slurp_to( parser, X_OPENTAG, X_NONE )) != NULL )
{
tag = malloc( sizeof(*tag) );
+ assert( tag );
tag->name = NULL;
tag->pcdata = pcdata;
tag->parent = parser->current_tag;
#endif
tag = malloc( sizeof(*tag) );
+ assert( tag );
tag->name = name;
tag->pcdata = NULL;
tag->parent = parser->current_tag;
}
wrapper = malloc( sizeof(XTag) );
+ assert( wrapper );
wrapper->name = NULL;
wrapper->pcdata = NULL;
wrapper->parent = NULL;
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_block.h>
#include <vlc_codecs.h>
+#include <vlc_memory.h>
/*****************************************************************************
* Module descriptor
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( p_sys->idx1.entry,
- p_sys->idx1.i_entry_max * sizeof( avi_idx1_entry_t ) );
+ p_sys->idx1.entry = realloc_or_free( 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 );
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_block.h>
+#include <vlc_memory.h>
#include <time.h>
if( p_stream->i_entry_count >= p_stream->i_entry_max - 1 )
{
p_stream->i_entry_max += 1000;
- p_stream->entry =
- realloc( p_stream->entry,
+ p_stream->entry = realloc_or_free( p_stream->entry,
p_stream->i_entry_max * sizeof( mp4_entry_t ) );
+ assert( p_stream->entry );
}
/* update */
{
p_bo->i_buffer_size = __MAX( i_size, 1024 );
p_bo->p_buffer = malloc( p_bo->i_buffer_size );
+ assert( p_bo->p_buffer );
}
else
{
else if( p_bo->b_grow )
{
p_bo->i_buffer_size += 1024;
- p_bo->p_buffer = realloc( p_bo->p_buffer, p_bo->i_buffer_size );
-
+ 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[p_bo->i_buffer] = i;
}
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_block.h>
#include <vlc_codecs.h>
+#include <vlc_memory.h>
#include <ogg/ogg.h>
/* move input in delete queue */
if( !p_stream->b_new )
{
- p_sys->pp_del_streams = realloc( p_sys->pp_del_streams,
- (p_sys->i_del_streams + 1) *
- sizeof(ogg_stream_t *) );
+ p_sys->pp_del_streams = realloc_or_free( 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
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_codec.h>
#include <vlc_block.h>
+#include <vlc_memory.h>
#include <vlc_bits.h>
#include <vlc_block_helper.h>
/* 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 );
memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra,
p_dec->fmt_in.i_extra );
if( (size_t)p_dec->fmt_out.i_extra != p_frag->i_buffer )
{
p_dec->fmt_out.p_extra =
- realloc( p_dec->fmt_out.p_extra, p_frag->i_buffer );
+ realloc_or_free( p_dec->fmt_out.p_extra, p_frag->i_buffer );
+ assert( p_dec->fmt_out.p_extra );
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 );
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
#include <vlc_block.h>
+#include <vlc_memory.h>
#include <vlc_bits.h>
#include <vlc_block_helper.h>
/* 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 );
packetizer_Init( &p_sys->packetizer,
p_vc1_startcode, sizeof(p_vc1_startcode),
if( p_es->i_extra != i_extra )
{
p_es->i_extra = i_extra;
- p_es->p_extra = realloc( p_dec->fmt_out.p_extra, p_es->i_extra );
+ p_es->p_extra = realloc_or_free( p_es->p_extra, p_es->i_extra );
+ assert( p_es->p_extra );
}
memcpy( p_es->p_extra,
p_sys->sh.p_sh->p_buffer, p_sys->sh.p_sh->i_buffer );
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 );
p_demux->p_sys->p_sdp = p_sdp;
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_block.h>
+#include <vlc_memory.h>
/*****************************************************************************
* Module descriptor
p_stream->p_cfg );
p_sys = malloc( sizeof( out_sout_stream_sys_t ) );
+ assert( p_sys );
p_sys->b_inited = false;
var_Create( p_this->p_libvlc, "bridge-lock", VLC_VAR_MUTEX );
if ( p_bridge == NULL )
{
p_bridge = malloc( sizeof( bridge_t ) );
+ assert( p_bridge );
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 );
if ( i == p_bridge->i_es_num )
{
- p_bridge->pp_es = realloc( p_bridge->pp_es,
- (p_bridge->i_es_num + 1)
- * sizeof(bridged_es_t *) );
+ p_bridge->pp_es = realloc_or_free( 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_sys->p_es = p_es = p_bridge->pp_es[i];
vlc_value_t val;
p_sys = malloc( sizeof( in_sout_stream_sys_t ) );
+ assert( p_sys );
p_sys->p_out = sout_StreamNew( p_stream->p_sout, p_stream->psz_next );
if( !p_sys->p_out )
#include <vlc_image.h>
#include <vlc_filter.h>
+#include <vlc_memory.h>
+
#include "../video_filter/mosaic.h"
#include <assert.h>
vlc_value_t val;
p_bridge = malloc( sizeof( bridge_t ) );
+ assert( p_bridge );
var_Create( p_libvlc, "mosaic-struct", VLC_VAR_ADDRESS );
val.p_address = p_bridge;
if ( i == p_bridge->i_es_num )
{
- p_bridge->pp_es = realloc( p_bridge->pp_es,
- (p_bridge->i_es_num + 1)
- * sizeof(bridged_es_t *) );
+ p_bridge->pp_es = realloc_or_free( 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_sys->p_es = p_es = p_bridge->pp_es[i];
#include <vlc_gcrypt.h>
#include <vlc_es.h>
#include <vlc_http.h>
+#include <vlc_memory.h>
#define RAOP_PORT 5000
#define RAOP_USER_AGENT "VLC " VERSION
/* Grow in blocks of 4K */
i_realloc_len = (1 + (i_len / 4096)) * 4096;
- p_sys->p_sendbuf = realloc( p_sys->p_sendbuf, i_realloc_len );
+ p_sys->p_sendbuf = realloc_or_free( p_sys->p_sendbuf, i_realloc_len );
if ( p_sys->p_sendbuf == NULL )
goto error;
#include <vlc_image.h>
#include <vlc_osd.h>
+#include <vlc_memory.h>
+
#ifdef LoadImage
# undef LoadImage
#endif
res = strtok_r(i_values, delim, &tok);
while (res != NULL) {
p_BarGraph->nbChannels++;
- p_BarGraph->i_values = (int*)realloc(p_BarGraph->i_values, p_BarGraph->nbChannels*sizeof(int));
+ p_BarGraph->i_values = realloc_or_free(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);
}
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
+#include <vlc_memory.h>
#define BLUESCREEN_HELP N_( \
"This effect, also known as \"greenscreen\" or \"chroma key\" blends " \
return NULL;
}
- p_sys->p_at = realloc( p_sys->p_at, i_lines * i_pitch * sizeof( uint8_t ) );
+ p_sys->p_at = realloc_or_free( p_sys->p_at,
+ i_lines * i_pitch * sizeof( uint8_t ) );
+ assert( p_sys->p_at );
p_at = p_sys->p_at;
vlc_mutex_lock( &p_sys->lock );
#include <vlc_common.h>
#include <vlc_osd.h>
+#include <vlc_memory.h>
#include <fcntl.h>
#include "dynamicoverlay.h"
/* Have to expand */
size_t i_size = p_list->pp_tail - p_list->pp_head;
size_t i_newsize = i_size * 2;
- p_list->pp_head = realloc( p_list->pp_head,
- i_newsize * sizeof( overlay_t * ) );
+ p_list->pp_head = realloc_or_free( p_list->pp_head,
+ i_newsize * sizeof( overlay_t * ) );
if( p_list->pp_head == NULL )
return VLC_ENOMEM;
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
+#include <vlc_memory.h>
#include <vlc_filter.h>
#include "filter_picture.h"
type_t *pt_distribution = malloc( (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) );
}
if( !p_sys->pt_buffer )
{
- p_sys->pt_buffer = realloc( p_sys->pt_buffer,
- p_pic->p[Y_PLANE].i_visible_lines *
- p_pic->p[Y_PLANE].i_pitch *
- sizeof( type_t ) );
+ p_sys->pt_buffer = realloc_or_free( p_sys->pt_buffer,
+ p_pic->p[Y_PLANE].i_visible_lines *
+ p_pic->p[Y_PLANE].i_pitch * sizeof( type_t ) );
}
pt_buffer = p_sys->pt_buffer;
p_sys->pt_scale = malloc( 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++ )
{
#include <math.h>
#include <limits.h> /* INT_MAX */
+#include <assert.h>
#include <vlc_filter.h>
#include <vlc_image.h>
+#include <vlc_memory.h>
+
#include "mosaic.h"
#define BLANK_DELAY INT64_C(1000000)
{
i_index++;
- p_sys->pi_x_offsets =
- realloc( p_sys->pi_x_offsets, i_index * sizeof(int) );
+ p_sys->pi_x_offsets = realloc_or_free( 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( p_sys->pi_y_offsets, i_index * sizeof(int) );
+ p_sys->pi_y_offsets = realloc_or_free( 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;
{
psz_end = strchr( psz_order, ',' );
i_index++;
- p_sys->ppsz_order = realloc( p_sys->ppsz_order,
- i_index * sizeof(char *) );
+ p_sys->ppsz_order = realloc_or_free( 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;
{
psz_end = strchr( psz_order, ',' );
i_index++;
- p_sys->ppsz_order = realloc( p_sys->ppsz_order,
- i_index * sizeof(char *) );
+ p_sys->ppsz_order = realloc_or_free( 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;
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_image.h>
+#include <vlc_memory.h>
+
#include <time.h>
/*****************************************************************************
{
b_is_item = true;
p_feed->i_items++;
- p_feed->p_items = realloc( p_feed->p_items,
- p_feed->i_items * sizeof( rss_item_t ) );
+ p_feed->p_items = realloc_or_free( 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;
#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_playlist.h> /* needed for wallpaper */
+#include <vlc_memory.h>
#include <ddraw.h>
#include <commctrl.h> /* ListView_(Get|Set)* */
module_config_t *p_item = (module_config_t *)p_context;
- p_item->ppsz_list =
- (char **)realloc( p_item->ppsz_list,
+ p_item->ppsz_list = realloc_or_free( p_item->ppsz_list,
(p_item->i_list+2) * sizeof(char *) );
- p_item->ppsz_list_text =
- (char **)realloc( p_item->ppsz_list_text,
+ assert( p_item->ppsz_list );
+ p_item->ppsz_list_text = realloc_or_free( 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;