mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: rename unregister_trip() to remove_trip()
For consistency with remove_dive(). Moreover, swap parameter order in remove_dive() so that both functions use the same parameter order. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
8dcc33d8ab
commit
dc9427d16a
5 changed files with 11 additions and 12 deletions
|
@ -407,7 +407,7 @@ struct dive *unregister_dive(int idx);
|
|||
extern void delete_single_dive(int idx);
|
||||
|
||||
extern void insert_trip(dive_trip_t *trip, struct trip_table *trip_table_arg);
|
||||
extern void unregister_trip(dive_trip_t *trip, struct trip_table *trip_table_arg);
|
||||
extern void remove_trip(dive_trip_t *trip, struct trip_table *trip_table_arg);
|
||||
extern void free_trip(dive_trip_t *trip);
|
||||
extern timestamp_t trip_date(const struct dive_trip *trip);
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* divelist.c */
|
||||
/* core logic for the dive list */
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -916,7 +915,7 @@ static MAKE_GET_IDX(trip_table, struct dive_trip *, trips)
|
|||
MAKE_SORT(dive_table, struct dive *, dives, comp_dives)
|
||||
MAKE_SORT(trip_table, struct dive_trip *, trips, comp_trips)
|
||||
|
||||
void remove_dive(struct dive_table *table, const struct dive *dive)
|
||||
void remove_dive(const struct dive *dive, struct dive_table *table)
|
||||
{
|
||||
int idx = get_idx_in_dive_table(table, dive);
|
||||
if (idx >= 0)
|
||||
|
@ -934,14 +933,14 @@ struct dive_trip *unregister_dive_from_trip(struct dive *dive)
|
|||
if (!trip)
|
||||
return NULL;
|
||||
|
||||
remove_dive(&trip->dives, dive);
|
||||
remove_dive(dive, &trip->dives);
|
||||
dive->divetrip = NULL;
|
||||
return trip;
|
||||
}
|
||||
|
||||
static void delete_trip(dive_trip_t *trip, struct trip_table *trip_table_arg)
|
||||
{
|
||||
unregister_trip(trip, trip_table_arg);
|
||||
remove_trip(trip, trip_table_arg);
|
||||
free_trip(trip);
|
||||
}
|
||||
|
||||
|
@ -1004,7 +1003,7 @@ dive_trip_t *create_and_hookup_trip_from_dive(struct dive *dive, struct trip_tab
|
|||
|
||||
/* remove trip from the trip-list, but don't free its memory.
|
||||
* caller takes ownership of the trip. */
|
||||
void unregister_trip(dive_trip_t *trip, struct trip_table *trip_table_arg)
|
||||
void remove_trip(dive_trip_t *trip, struct trip_table *trip_table_arg)
|
||||
{
|
||||
int idx = get_idx_in_trip_table(trip_table_arg, trip);
|
||||
assert(!trip->dives.nr);
|
||||
|
@ -1476,7 +1475,7 @@ static bool merge_dive_tables(struct dive_table *dives_from, struct dive_table *
|
|||
struct dive *dive_to_add = dives_from->dives[i];
|
||||
|
||||
if (delete_from)
|
||||
remove_dive(delete_from, dive_to_add);
|
||||
remove_dive(dive_to_add, delete_from);
|
||||
|
||||
/* Find insertion point. */
|
||||
while (j < dives_to->nr && dive_less_than(dives_to->dives[j], dive_to_add))
|
||||
|
@ -1759,7 +1758,7 @@ void process_imported_dives(struct dive_table *import_table, struct trip_table *
|
|||
insert_dive(dives_to_add, d);
|
||||
sequence_changed |= !dive_is_after_last(d);
|
||||
|
||||
remove_dive(import_table, d);
|
||||
remove_dive(d, import_table);
|
||||
}
|
||||
|
||||
/* Then, add trip to list of trips to add */
|
||||
|
|
|
@ -38,7 +38,7 @@ 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);
|
||||
extern struct dive_trip *unregister_dive_from_trip(struct dive *dive);
|
||||
extern void remove_dive(struct dive_table *table, const struct dive *dive);
|
||||
extern void remove_dive(const struct dive *dive, struct dive_table *table);
|
||||
extern void remove_dive_from_trip(struct dive *dive, struct trip_table *trip_table_arg);
|
||||
extern dive_trip_t *alloc_trip(void);
|
||||
extern dive_trip_t *create_trip_from_dive(struct dive *dive);
|
||||
|
|
|
@ -391,7 +391,7 @@ struct dive_site *unregister_dive_from_dive_site(struct dive *d)
|
|||
struct dive_site *ds = d->dive_site;
|
||||
if (!ds)
|
||||
return NULL;
|
||||
remove_dive(&ds->dives, d);
|
||||
remove_dive(d, &ds->dives);
|
||||
d->dive_site = NULL;
|
||||
return ds;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ DiveToAdd DiveListBase::removeDive(struct dive *d, std::vector<OwningTripPtr> &t
|
|||
diveSiteCountChanged(d->dive_site);
|
||||
res.site = unregister_dive_from_dive_site(d);
|
||||
if (res.trip && res.trip->dives.nr == 0) {
|
||||
unregister_trip(res.trip, &trip_table); // Remove trip from backend
|
||||
remove_trip(res.trip, &trip_table); // Remove trip from backend
|
||||
tripsToAdd.emplace_back(res.trip); // Take ownership of trip
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ static OwningTripPtr moveDiveToTrip(DiveToTrip &diveToTrip)
|
|||
// Remove dive from trip - if this is the last dive in the trip, remove the whole trip.
|
||||
dive_trip *trip = unregister_dive_from_trip(diveToTrip.dive);
|
||||
if (trip && trip->dives.nr == 0) {
|
||||
unregister_trip(trip, &trip_table); // Remove trip from backend
|
||||
remove_trip(trip, &trip_table); // Remove trip from backend
|
||||
res.reset(trip);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue