summaryrefslogtreecommitdiffstats
path: root/core/divelist.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-06-04 20:59:08 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-06-19 13:11:10 -0700
commit3df32044ee46caf518b23cc6359f98501f7ca961 (patch)
tree860615069cf0b5f36627b0815d374c66e265dbde /core/divelist.c
parentf4ef1c4bc8805600e018777f18f3f29682e40c2d (diff)
downloadsubsurface-3df32044ee46caf518b23cc6359f98501f7ca961.tar.gz
Cleanup: generate clear_*_table() functions by macro
In analogy to the other table functions, generate these by a macro as well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/divelist.c')
-rw-r--r--core/divelist.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/core/divelist.c b/core/divelist.c
index 71391d505..af253fb4e 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -782,6 +782,7 @@ static MAKE_REMOVE_FROM(dive_table, dives)
static MAKE_GET_IDX(dive_table, struct dive *, dives)
MAKE_SORT(dive_table, struct dive *, dives, comp_dives)
MAKE_REMOVE(dive_table, struct dive *, dive)
+MAKE_CLEAR_TABLE(dive_table, dives, dive)
void insert_dive(struct dive_table *table, struct dive *d)
{
@@ -1009,23 +1010,6 @@ static void merge_imported_dives(struct dive_table *table)
}
/*
- * Clear a dive_table and dive_site_table. Think about generating these with macros.
- */
-void clear_table(struct dive_table *table)
-{
- for (int i = 0; i < table->nr; i++)
- free_dive(table->dives[i]);
- table->nr = 0;
-}
-
-void clear_dive_site_table(struct dive_site_table *ds_table)
-{
- for (int i = 0; i < ds_table->nr; i++)
- free_dive_site(ds_table->dive_sites[i]);
- ds_table->nr = 0;
-}
-
-/*
* Try to merge a new dive into the dive at position idx. Return
* true on success. On success, the old dive will be added to the
* dives_to_remove table and the merged dive to the dives_to_add
@@ -1292,8 +1276,8 @@ void process_imported_dives(struct dive_table *import_table, struct trip_table *
import_trip_table = &local_trip_table;
/* Make sure that output parameters don't contain garbage */
- clear_table(dives_to_add);
- clear_table(dives_to_remove);
+ clear_dive_table(dives_to_add);
+ clear_dive_table(dives_to_remove);
clear_trip_table(trips_to_add);
clear_dive_site_table(sites_to_add);