]> git.sesse.net Git - vlc/blobdiff - modules/control/http/util.c
Do not assert memory allocations
[vlc] / modules / control / http / util.c
index 70288be4e43a0ffe15694d2a59f1ab641a9864b9..d7d7cb4bf7d0c2777c1afe8a6d3253a75a7deddc 100644 (file)
 # 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
@@ -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 */