changeset 19891:55a39486f4a8

Fix a stupid bug in list concatenation.
author eugeni
date Mon, 18 Sep 2006 18:54:38 +0000
parents 441f1e2d7559
children 2c361743ce69
files libass/ass_render.c
diffstat 1 files changed, 9 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass_render.c	Mon Sep 18 17:32:20 2006 +0000
+++ b/libass/ass_render.c	Mon Sep 18 18:54:38 2006 +0000
@@ -1900,16 +1900,6 @@
 	return 0;
 }
 
-static ass_image_t** find_list_tail(ass_image_t** phead)
-{
-	ass_image_t* img = *phead;
-	if (!img)
-		return phead;
-	while (img->next)
-		img = img->next;
-	return &img->next;
-}
-
 static int cmp_event_layer(const void* p1, const void* p2)
 {
 	ass_event_t* e1 = ((event_images_t*)p1)->event;
@@ -2084,8 +2074,7 @@
 	int i, cnt, rc;
 	event_images_t eimg[MAX_EVENTS];
 	event_images_t* last;
-	ass_image_t* head = 0;
-	ass_image_t** tail = &head;
+	ass_image_t** tail;
 	
 	// init frame
 	rc = ass_start_frame(priv, track, now);
@@ -2121,14 +2110,16 @@
 		fix_collisions(last, eimg + cnt - last);
 
 	// concat lists
-	head = cnt ? eimg[0].imgs : 0;
-	tail = find_list_tail(&head);
-	for (i = 1; i < cnt; ++i) {
-		*tail = eimg[i].imgs;
-		tail = find_list_tail(&eimg[i].imgs);
+	tail = &ass_instance->images_root;
+	for (i = 0; i < cnt; ++i) {
+		ass_image_t* cur = eimg[i].imgs;
+		while (cur) {
+			*tail = cur;
+			tail = &cur->next;
+			cur = cur->next;
+		}
 	}
 	
-	ass_instance->images_root = head;
 	return ass_instance->images_root;
 }