]> granicus.if.org Git - libass/commitdiff
Allocate track array exponentially
authorwm4 <wm4@nowhere>
Thu, 23 Jan 2014 17:38:51 +0000 (18:38 +0100)
committerwm4 <wm4@nowhere>
Fri, 24 Jan 2014 00:00:48 +0000 (01:00 +0100)
This reduces the frequency of reallocations.

libass/ass.c

index aa492467c3b7bfa3bdf34d36782a5c2f5c7e263f..c45adaf494f9acedc105e2ff4078d1c5630a7ddb 100644 (file)
@@ -57,7 +57,6 @@ struct parser_priv {
 };
 
 #define ASS_STYLES_ALLOC 20
-#define ASS_EVENTS_ALLOC 200
 
 int ass_library_version(void)
 {
@@ -122,7 +121,7 @@ int ass_alloc_event(ASS_Track *track)
     assert(track->n_events <= track->max_events);
 
     if (track->n_events == track->max_events) {
-        track->max_events += ASS_EVENTS_ALLOC;
+        track->max_events = track->max_events * 2 + 1;
         track->events =
             (ASS_Event *) realloc(track->events,
                                   sizeof(ASS_Event) *