diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-11-24 10:11:07 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-01-09 20:58:04 -0800 |
commit | d1971a64f954b001729a0270e2f28bf8fa3f1a4a (patch) | |
tree | 2c00c5d04591e01ac3a4b78ea68fb95de08ce19f /core | |
parent | 2802d4296960eb6ad76292baa105075c5427ea67 (diff) | |
download | subsurface-d1971a64f954b001729a0270e2f28bf8fa3f1a4a.tar.gz |
Core: Rename functions to more generic names
Rename
- dive_get_insertion_index() -> dive_table_get_insertion_index()
- unregister_dive_from_table() -> remove_from_dive_table()
- get_idx_in_table() -> get_idx_in_dive_table()
- sort_table() -> sort_dive_table()
This will make it more straight-forward to generate these functions
from macros.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r-- | core/datatrak.c | 2 | ||||
-rw-r--r-- | core/dive.h | 2 | ||||
-rw-r--r-- | core/divelist.c | 24 | ||||
-rw-r--r-- | core/divelist.h | 2 | ||||
-rw-r--r-- | core/ostctools.c | 2 |
5 files changed, 16 insertions, 16 deletions
diff --git a/core/datatrak.c b/core/datatrak.c index 1c6cd8bb1..931fcb811 100644 --- a/core/datatrak.c +++ b/core/datatrak.c @@ -610,7 +610,7 @@ int datatrak_import(struct memblock *mem, struct dive_table *table) } out: taglist_cleanup(&g_tag_list); - sort_table(table); + sort_dive_table(table); return rc; bail: return 1; diff --git a/core/dive.h b/core/dive.h index a93020507..a6210810d 100644 --- a/core/dive.h +++ b/core/dive.h @@ -542,7 +542,7 @@ extern int legacy_format_o2pressures(const struct dive *dive, const struct divec extern bool dive_less_than(const struct dive *a, const struct dive *b); extern bool trip_less_than(const struct dive_trip *a, const struct dive_trip *b); extern bool dive_or_trip_less_than(struct dive_or_trip a, struct dive_or_trip b); -extern void sort_table(struct dive_table *table); +extern void sort_dive_table(struct dive_table *table); extern struct dive *fixup_dive(struct dive *dive); extern void fixup_dc_duration(struct divecomputer *dc); extern int dive_getUniqID(); diff --git a/core/divelist.c b/core/divelist.c index c25a29c16..febc8adb7 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -37,7 +37,7 @@ * bool dive_less_than(const struct dive *a, const struct dive *b) * bool trip_less_than(const struct dive_trip *a, const struct dive_trip *b) * bool dive_or_trip_less_than(struct dive_or_trip a, struct dive_or_trip b) - * void sort_table(struct dive_table *table) + * void sort_dive_table(struct dive_table *table) * bool is_trip_before_after(const struct dive *dive, bool before) * void delete_dive_from_table(struct dive_table *table, int idx) * int find_next_visible_dive(timestamp_t when); @@ -498,7 +498,7 @@ static void add_dive_to_deco(struct deco_state *ds, struct dive *dive) } } -static int get_idx_in_table(const struct dive_table *table, const struct dive *dive) +static int get_idx_in_dive_table(const struct dive_table *table, const struct dive *dive) { for (int i = 0; i < table->nr; ++i) { if (table->dives[i] == dive) @@ -885,7 +885,7 @@ static void add_to_dive_table(struct dive_table *table, int idx, struct dive *di } } -static void unregister_dive_from_table(struct dive_table *table, int idx) +static void remove_from_dive_table(struct dive_table *table, int idx) { int i; for (i = idx; i < table->nr - 1; i++) @@ -905,9 +905,9 @@ struct dive_trip *unregister_dive_from_trip(struct dive *dive) if (!trip) return NULL; - idx = get_idx_in_table(&trip->dives, dive); + idx = get_idx_in_dive_table(&trip->dives, dive); if (idx >= 0) - unregister_dive_from_table(&trip->dives, idx); + remove_from_dive_table(&trip->dives, idx); dive->divetrip = NULL; return trip; } @@ -928,7 +928,7 @@ void add_dive_to_trip(struct dive *dive, dive_trip_t *trip) return; if (dive->divetrip) fprintf(stderr, "Warning: adding dive to trip that has trip set\n"); - idx = dive_get_insertion_index(&trip->dives, dive); + idx = dive_table_get_insertion_index(&trip->dives, dive); add_to_dive_table(&trip->dives, idx, dive); dive->divetrip = trip; } @@ -1086,7 +1086,7 @@ static void autogroup_dives(struct dive_table *table) void delete_dive_from_table(struct dive_table *table, int idx) { free_dive(table->dives[idx]); - unregister_dive_from_table(table, idx); + remove_from_dive_table(table, idx); } /* This removes a dive from the global dive table but doesn't free the @@ -1098,7 +1098,7 @@ struct dive *unregister_dive(int idx) struct dive *dive = get_dive(idx); if (!dive) return NULL; /* this should never happen */ - unregister_dive_from_table(&dive_table, idx); + remove_from_dive_table(&dive_table, idx); if (dive->selected) amount_selected--; dive->selected = false; @@ -1136,7 +1136,7 @@ struct dive **grow_dive_table(struct dive_table *table) /* get the index where we want to insert the dive so that everything stays * ordered according to dive_less_than() */ -int dive_get_insertion_index(struct dive_table *table, struct dive *dive) +int dive_table_get_insertion_index(struct dive_table *table, struct dive *dive) { /* we might want to use binary search here */ for (int i = 0; i < table->nr; i++) { @@ -1352,7 +1352,7 @@ void process_loaded_dives() for_each_dive(i, dive) set_dc_nickname(dive); - sort_table(&dive_table); + sort_dive_table(&dive_table); /* Autogroup dives if desired by user. */ autogroup_dives(&dive_table); @@ -1448,7 +1448,7 @@ void process_imported_dives(struct dive_table *import_table, bool prefer_importe set_dc_nickname(import_table->dives[i]); /* Sort the table of dives to be imported and combine mergable dives */ - sort_table(import_table); + sort_dive_table(import_table); merge_imported_dives(import_table); /* Merge newly imported dives into the dive table. @@ -1703,7 +1703,7 @@ static int sortfn(const void *_a, const void *_b) return comp_dives(a, b); } -void sort_table(struct dive_table *table) +void sort_dive_table(struct dive_table *table) { qsort(table->dives, table->nr, sizeof(struct dive *), sortfn); } diff --git a/core/divelist.h b/core/divelist.h index aca2ed21e..49e161191 100644 --- a/core/divelist.h +++ b/core/divelist.h @@ -22,7 +22,7 @@ extern void process_imported_dives(struct dive_table *import_table, bool prefer_ extern char *get_dive_gas_string(const struct dive *dive); extern struct dive **grow_dive_table(struct dive_table *table); -extern int dive_get_insertion_index(struct dive_table *table, struct dive *dive); +extern int dive_table_get_insertion_index(struct dive_table *table, struct dive *dive); extern void add_single_dive(int idx, struct dive *dive); extern void get_dive_gas(const struct dive *dive, int *o2_p, int *he_p, int *o2low_p); extern int get_divenr(const struct dive *dive); diff --git a/core/ostctools.c b/core/ostctools.c index 84ef23301..f0fa6a634 100644 --- a/core/ostctools.c +++ b/core/ostctools.c @@ -188,7 +188,7 @@ void ostctools_import(const char *file, struct dive_table *divetable) } record_dive_to_table(ostcdive, divetable); mark_divelist_changed(true); - sort_table(divetable); + sort_dive_table(divetable); close_out: fclose(archive); |