aboutsummaryrefslogtreecommitdiff
path: root/util/range.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/range.c')
-rw-r--r--util/range.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/util/range.c b/util/range.c
index f775f2e673..dd460926a8 100644
--- a/util/range.c
+++ b/util/range.c
@@ -44,14 +44,26 @@ static void range_merge(Range *range1, Range *range2)
}
}
-GList *g_list_insert_sorted_merged(GList *list, gpointer data,
- GCompareFunc func)
+static gint range_compare(gconstpointer a, gconstpointer b)
+{
+ Range *ra = (Range *)a, *rb = (Range *)b;
+ if (ra->begin == rb->begin && ra->end == rb->end) {
+ return 0;
+ } else if (range_get_last(ra->begin, ra->end) <
+ range_get_last(rb->begin, rb->end)) {
+ return -1;
+ } else {
+ return 1;
+ }
+}
+
+GList *range_list_insert(GList *list, Range *data)
{
GList *l, *next = NULL;
Range *r, *nextr;
if (!list) {
- list = g_list_insert_sorted(list, data, func);
+ list = g_list_insert_sorted(list, data, range_compare);
return list;
}
@@ -74,7 +86,7 @@ GList *g_list_insert_sorted_merged(GList *list, gpointer data,
}
if (!l) {
- list = g_list_insert_sorted(list, data, func);
+ list = g_list_insert_sorted(list, data, range_compare);
}
return list;