GNOME Bugzilla – Bug 679695
toc: improvement gst_toc_find_entry()
Last modified: 2012-07-11 14:11:36 UTC
Created attachment 218446 [details] [review] [PATCH] toc: improvement gst_toc_find_entry() Previously gst_toc_find_entry () returns the top-level entry. I think this bad, because impossible found needed entry on second, third, etc levels. Now, this function returns the entry with the UID on different levels, because the search recursively. I'm bad at English, but I hope that you understand my idea. If patch will be commited, please fix commit message (reason above). Many thanks.
Comment on attachment 218446 [details] [review] [PATCH] toc: improvement gst_toc_find_entry() From 471917e6f2f0435f2a712b94e7fd5b1efd0d7587 Mon Sep 17 00:00:00 2001 From: Anton Belka <antonbelka@gmail.com> Date: Tue, 10 Jul 2012 18:15:20 +0300 Subject: [PATCH] toc: improvement gst_toc_find_entry() Recursive search for the required entry. Instead of return top-level entry, return entry with needed UID. --- gst/gsttoc.c | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-) diff --git a/gst/gsttoc.c b/gst/gsttoc.c index c1e713a..95accc3 100644 --- a/gst/gsttoc.c +++ b/gst/gsttoc.c @@ -298,25 +298,29 @@ gst_toc_entry_free (GstTocEntry * entry) g_slice_free (GstTocEntry, entry); } -static gboolean -gst_toc_check_entry_for_uid (const GstTocEntry * entry, const gchar * uid) +static GstTocEntry * +gst_toc_check_subentries_for_uid (const GstTocEntry * entry, const gchar * uid) { GList *cur; + GstTocEntry *subentry, *tmp; g_return_val_if_fail (entry != NULL, FALSE); g_return_val_if_fail (uid != NULL, FALSE); - if (g_strcmp0 (entry->uid, uid) == 0) - return TRUE; - cur = entry->subentries; while (cur != NULL) { - if (gst_toc_check_entry_for_uid (cur->data, uid)) - return TRUE; + subentry = cur->data; + if (g_strcmp0 (subentry->uid, uid) == 0) { + return subentry; + } else { + tmp = gst_toc_check_subentries_for_uid (subentry, uid); + if (tmp != NULL) + return tmp; + } cur = cur->next; } - return FALSE; + return NULL; } /** @@ -334,14 +338,21 @@ GstTocEntry * gst_toc_find_entry (const GstToc * toc, const gchar * uid) { GList *cur; + GstTocEntry *entry, *subentry; g_return_val_if_fail (toc != NULL, NULL); g_return_val_if_fail (uid != NULL, NULL); cur = toc->entries; while (cur != NULL) { - if (gst_toc_check_entry_for_uid (cur->data, uid)) - return cur->data; + entry = cur->data; + if (g_strcmp0 (entry->uid, uid) == 0) { + return entry; + } else { + subentry = gst_toc_check_subentries_for_uid (entry, uid); + if (subentry != NULL) + return subentry; + } cur = cur->next; } -- 1.7.4.1
Right patch in second comment. Sorry. P.S. I will check all before sending patches. :)
Please attach instead of pasting into a comment in the future. Author: Anton Belka <antonbelka@gmail.com> Date: Tue Jul 10 18:15:20 2012 +0300 toc: Fix gst_toc_find_entry() Recursive search for the required entry, instead of returning the top-level entry that contains an entry with the search UID.
Sebastian, thanks for commit and fix. :)