]> git.sesse.net Git - vlc/blobdiff - modules/codec/speex.c
Do not assert memory allocations
[vlc] / modules / codec / speex.c
index d7ec977c194bd955cb3936252ad05199c26e4d64..f331c82be81d8111257bf7a4d3826301f038e619 100644 (file)
 # 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>
@@ -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;