[vlc-commits] demux: ttml: store array allocation

Francois Cartegnie git at videolan.org
Mon Jan 2 16:40:36 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jan  2 14:43:27 2017 +0100| [efb274242d78efadd2c0ba15d4bf49ae4e2aa1cf] | committer: Francois Cartegnie

demux: ttml: store array allocation

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=efb274242d78efadd2c0ba15d4bf49ae4e2aa1cf
---

 modules/demux/ttml.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/demux/ttml.c b/modules/demux/ttml.c
index 2606374..e6e8420 100644
--- a/modules/demux/ttml.c
+++ b/modules/demux/ttml.c
@@ -65,6 +65,7 @@ struct demux_sys_t
     {
         subtitle_t* p_array;
         size_t i_count;
+        size_t i_alloc;
         size_t i_current;
     } subs;
 
@@ -585,7 +586,6 @@ static int ReadTTML( demux_t* p_demux )
     node_t* p_node = NULL;
     char* psz_text = NULL;
     const char* psz_node_name;
-    int i_max_sub = 0;
     int i_type;
 
     do
@@ -626,11 +626,11 @@ static int ReadTTML( demux_t* p_demux )
 
                 if( p_node->psz_begin && p_node->psz_end )
                 {
-                    if( p_sys->subs.i_count >= i_max_sub )
+                    if( p_sys->subs.i_count >= p_sys->subs.i_alloc )
                     {
-                        i_max_sub += 500;
+                        p_sys->subs.i_alloc += 500;
                         subtitle_t* p_subtitles = realloc( p_sys->subs.p_array,
-                                sizeof( *p_sys->subs.p_array ) * i_max_sub );
+                                sizeof( *p_sys->subs.p_array ) * p_sys->subs.i_alloc );
                         if( unlikely( p_subtitles == NULL ) )
                             goto error;
                         p_sys->subs.p_array = p_subtitles;



More information about the vlc-commits mailing list