[tracker/miner-priority-queues: 5/22] libtracker-miner: Make tracker_priority_queue_foreach_remove return gboolean



commit a3a0a2191f9114126f43c6ede2a7e17b70f6f085
Author: Carlos Garnacho <carlos lanedo com>
Date:   Thu Jun 30 18:06:52 2011 +0200

    libtracker-miner: Make tracker_priority_queue_foreach_remove return gboolean
    
    it will return TRUE if some item has been removed, FALSE otherwise

 src/libtracker-miner/tracker-priority-queue.c |   12 ++++++++----
 src/libtracker-miner/tracker-priority-queue.h |    4 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-priority-queue.c b/src/libtracker-miner/tracker-priority-queue.c
index 4a9a24b..0fc9404 100644
--- a/src/libtracker-miner/tracker-priority-queue.c
+++ b/src/libtracker-miner/tracker-priority-queue.c
@@ -161,7 +161,7 @@ tracker_priority_queue_foreach (TrackerPriorityQueue *queue,
 	g_queue_foreach (&queue->queue, func, user_data);
 }
 
-void
+gboolean
 tracker_priority_queue_foreach_remove (TrackerPriorityQueue *queue,
                                        GEqualFunc            compare_func,
                                        gpointer              compare_user_data,
@@ -169,15 +169,16 @@ tracker_priority_queue_foreach_remove (TrackerPriorityQueue *queue,
 {
 	PrioritySegment *segment;
 	gint n_segment = 0;
+	gboolean updated = FALSE;
 	GList *list;
 
-	g_return_if_fail (queue != NULL);
-	g_return_if_fail (compare_func != NULL);
+	g_return_val_if_fail (queue != NULL, FALSE);
+	g_return_val_if_fail (compare_func != NULL, FALSE);
 
 	list = queue->queue.head;
 
 	if (!list) {
-		return;
+		return FALSE;
 	}
 
 	segment = &g_array_index (queue->segments, PrioritySegment, n_segment);
@@ -214,6 +215,7 @@ tracker_priority_queue_foreach_remove (TrackerPriorityQueue *queue,
 			}
 
 			g_queue_delete_link (&queue->queue, elem);
+			updated = TRUE;
 		} else {
 			if (list != NULL &&
 			    elem == segment->last_elem) {
@@ -227,6 +229,8 @@ tracker_priority_queue_foreach_remove (TrackerPriorityQueue *queue,
 			}
 		}
 	}
+
+	return updated;
 }
 
 gboolean
diff --git a/src/libtracker-miner/tracker-priority-queue.h b/src/libtracker-miner/tracker-priority-queue.h
index 9a530cc..2c24e1c 100644
--- a/src/libtracker-miner/tracker-priority-queue.h
+++ b/src/libtracker-miner/tracker-priority-queue.h
@@ -46,7 +46,7 @@ void     tracker_priority_queue_foreach (TrackerPriorityQueue *queue,
                                          GFunc                 func,
                                          gpointer              user_data);
 
-void     tracker_priority_queue_foreach_remove (TrackerPriorityQueue *queue,
+gboolean tracker_priority_queue_foreach_remove (TrackerPriorityQueue *queue,
                                                 GEqualFunc            compare_func,
                                                 gpointer              compare_user_data,
                                                 GDestroyNotify        destroy_notify);
@@ -54,7 +54,7 @@ void     tracker_priority_queue_foreach_remove (TrackerPriorityQueue *queue,
 gpointer tracker_priority_queue_find           (TrackerPriorityQueue *queue,
                                                 gint                 *priority_out,
                                                 GEqualFunc            compare_func,
-                                                gpointer              user_data);
+                                                gpointer              data);
 
 gpointer tracker_priority_queue_peek    (TrackerPriorityQueue *queue,
                                          gint                 *priority_out);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]