summaryrefslogtreecommitdiffstats
path: root/divesite.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-24 11:07:57 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-25 10:43:52 -0700
commit420afeef570cd4989dac60ac6376929ca1cc9a03 (patch)
tree81f0d9277902540c52789eb32cfdd672effd59a6 /divesite.c
parente03b553e80a00b07757f51f7866bc666b807dce8 (diff)
downloadsubsurface-420afeef570cd4989dac60ac6376929ca1cc9a03.tar.gz
Save XML: sort the dive sites by uuid
This makes it much easier to compare XML files written by Subsurface. The order of the dive_site_table depended on the order in which they were encountered. This makes it easier to eye-ball changes in XML files. And allows the GitStorage test to pass. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divesite.c')
-rw-r--r--divesite.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/divesite.c b/divesite.c
index 035c1b82d..93bd35e59 100644
--- a/divesite.c
+++ b/divesite.c
@@ -263,3 +263,15 @@ uint32_t find_or_create_dive_site_with_name(const char *name, timestamp_t diveti
return ds->uuid;
return create_dive_site(name, divetime);
}
+
+static int compare_sites(const void *_a, const void *_b)
+{
+ const struct dive_site *a = (const struct dive_site *)*(void **)_a;
+ const struct dive_site *b = (const struct dive_site *)*(void **)_b;
+ return a->uuid > b->uuid ? 1 : a->uuid == b->uuid ? 0 : -1;
+}
+
+void dive_site_table_sort()
+{
+ qsort(dive_site_table.dive_sites, dive_site_table.nr, sizeof(struct dive_site *), compare_sites);
+}