summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-08-01 21:57:24 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-02 08:55:08 -0700
commit8c036234e240078c4d2d594d2b69458496982b01 (patch)
tree0cfdb61a6ea502d885db4a74a4d87b9ef04defd6 /core
parent1c4a859c8d0b37b2e938209fe9c4d99e9758327a (diff)
downloadsubsurface-8c036234e240078c4d2d594d2b69458496982b01.tar.gz
Cleanup: move sort_table() from subsurface_startup.c to divelist.c
The function is not only used at startup and arguably belongs the the file with the rest of the low-level divelist functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/divelist.c19
-rw-r--r--core/subsurfacestartup.c17
2 files changed, 18 insertions, 18 deletions
diff --git a/core/divelist.c b/core/divelist.c
index a9b793517..b81e89d25 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -25,6 +25,7 @@
* void mark_divelist_changed(int changed)
* int unsaved_changes()
* void remove_autogen_trips()
+ * void sort_table(struct dive_table *table)
*/
#include <unistd.h>
#include <stdio.h>
@@ -1385,7 +1386,6 @@ int get_dive_id_closest_to(timestamp_t when)
return dive_table.dives[i]->id;
}
-
void clear_dive_file_data()
{
while (dive_table.nr)
@@ -1399,3 +1399,20 @@ void clear_dive_file_data()
reset_min_datafile_version();
saved_git_id = "";
}
+
+static int sortfn(const void *_a, const void *_b)
+{
+ const struct dive *a = (const struct dive *)*(void **)_a;
+ const struct dive *b = (const struct dive *)*(void **)_b;
+
+ if (a->when < b->when)
+ return -1;
+ if (a->when > b->when)
+ return 1;
+ return 0;
+}
+
+void sort_table(struct dive_table *table)
+{
+ qsort(table->dives, table->nr, sizeof(struct dive *), sortfn);
+}
diff --git a/core/subsurfacestartup.c b/core/subsurfacestartup.c
index 2bb905217..1210004cb 100644
--- a/core/subsurfacestartup.c
+++ b/core/subsurfacestartup.c
@@ -112,23 +112,6 @@ struct units *get_units()
}
/* random helper functions, used here or elsewhere */
-static int sortfn(const void *_a, const void *_b)
-{
- const struct dive *a = (const struct dive *)*(void **)_a;
- const struct dive *b = (const struct dive *)*(void **)_b;
-
- if (a->when < b->when)
- return -1;
- if (a->when > b->when)
- return 1;
- return 0;
-}
-
-void sort_table(struct dive_table *table)
-{
- qsort(table->dives, table->nr, sizeof(struct dive *), sortfn);
-}
-
const char *monthname(int mon)
{
static const char month_array[12][7] = {