]> git.sesse.net Git - vlc/commitdiff
asx.c: change reallocating to doupling instead of adding just 1024
authorIlkka Ollakka <ileoo@videolan.org>
Mon, 12 Oct 2009 13:33:12 +0000 (16:33 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Tue, 13 Oct 2009 08:52:23 +0000 (11:52 +0300)
Also change comparing stream size from (<=0 && < 16384) to (<=0 && >16384)

modules/demux/playlist/asx.c

index dc865bff699785d3afb6cdc122f3adc4496d49fd..9cfb7a4efaf6f88f0172c27de63b8910c450b47c 100644 (file)
@@ -240,8 +240,8 @@ static int Demux( demux_t *p_demux )
     if( p_sys->i_data_len < 0 )
     {
         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->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);
 
         /* load the complete file */
@@ -252,10 +252,9 @@ static int Demux( demux_t *p_demux )
 
             if( i_read < p_sys->i_data_len - i_pos ) break; /* Done */
 
-            /* XXX this looks fishy and inefficient */
             i_pos += i_read;
-            p_sys->i_data_len += 1024;
-            p_sys->psz_data = realloc( p_sys->psz_data, p_sys->i_data_len * sizeof( char * ) +1 );
+            p_sys->i_data_len <<= 1 ;
+            p_sys->psz_data = realloc( p_sys->psz_data, p_sys->i_data_len * sizeof( char * ) + 1 );
         }
         if( p_sys->i_data_len <= 0 ) return -1;
     }