From f182072a290863fda6aeafe04176b40b8ec49fa6 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 10 Aug 2012 16:52:11 +0200 Subject: [PATCH] log-store-xml: Filter out duplicate dates in get_dates Fixes: https://bugs.freedesktop.org/53345 --- telepathy-logger/log-store-xml.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c index 2ec534f..160bc5c 100644 --- a/telepathy-logger/log-store-xml.c +++ b/telepathy-logger/log-store-xml.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2003-2007 Imendio AB * Copyright (C) 2007-2011 Collabora Ltd. + * Copyright (C) 2012 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -921,6 +922,7 @@ log_store_xml_get_dates (TplLogStore *store, { TplLogStoreXml *self = (TplLogStoreXml *) store; GList *dates = NULL; + GList *l; gchar *directory = NULL; GDir *dir = NULL; GString *pattern = NULL; @@ -973,6 +975,31 @@ log_store_xml_get_dates (TplLogStore *store, g_free (str); } + /* Filter out duplicate dates in-place */ + l = g_list_first (dates); + while (TRUE) + { + GList *m; + GList *tmp; + + m = g_list_next (l); + if (m == NULL) + break; + + if (g_date_compare ((GDate *) l->data, (GDate *) m->data) == 0) + { + g_date_free ((GDate *) m->data); + + /* Silence -Wunused-result -- the first node in the list + * should never change. + */ + tmp = g_list_delete_link (dates, m); + tmp = tmp; /* Silence -Wunused-but-set-variable */ + } + else + l = m; + } + out: g_free (directory); -- 1.7.11.2