mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
1c4a859c8d
commit
8c036234e2
2 changed files with 18 additions and 18 deletions
|
|
@ -25,6 +25,7 @@
|
||||||
* void mark_divelist_changed(int changed)
|
* void mark_divelist_changed(int changed)
|
||||||
* int unsaved_changes()
|
* int unsaved_changes()
|
||||||
* void remove_autogen_trips()
|
* void remove_autogen_trips()
|
||||||
|
* void sort_table(struct dive_table *table)
|
||||||
*/
|
*/
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -1385,7 +1386,6 @@ int get_dive_id_closest_to(timestamp_t when)
|
||||||
return dive_table.dives[i]->id;
|
return dive_table.dives[i]->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void clear_dive_file_data()
|
void clear_dive_file_data()
|
||||||
{
|
{
|
||||||
while (dive_table.nr)
|
while (dive_table.nr)
|
||||||
|
|
@ -1399,3 +1399,20 @@ void clear_dive_file_data()
|
||||||
reset_min_datafile_version();
|
reset_min_datafile_version();
|
||||||
saved_git_id = "";
|
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);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,23 +112,6 @@ struct units *get_units()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* random helper functions, used here or elsewhere */
|
/* 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)
|
const char *monthname(int mon)
|
||||||
{
|
{
|
||||||
static const char month_array[12][7] = {
|
static const char month_array[12][7] = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue