summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-01-08 21:25:02 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-01-10 02:37:03 +0900
commite1cd055111cc4f7e11454b3726741f9f8a55d850 (patch)
treebb391d65743da3285367ec1f1803925978db6877 /core
parent70cabb968c481e566e8249465f153e05e6dc0347 (diff)
downloadsubsurface-e1cd055111cc4f7e11454b3726741f9f8a55d850.tar.gz
code cleanup: add empty table structures
It seemed to make sense to combine all three types in one commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/dive.h2
-rw-r--r--core/divelist.c10
-rw-r--r--core/divesite.h2
-rw-r--r--core/trip.h2
4 files changed, 11 insertions, 5 deletions
diff --git a/core/dive.h b/core/dive.h
index b642c3031..e54006dd8 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -133,6 +133,8 @@ typedef struct dive_table {
struct dive **dives;
} dive_table_t;
+static const dive_table_t empty_dive_table = { 0, 0, (struct dive **)0 };
+
struct picture;
struct dive_site;
struct dive_site_table;
diff --git a/core/divelist.c b/core/divelist.c
index 48f5a270c..6995c4c50 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -992,10 +992,10 @@ static bool merge_dive_tables(struct dive_table *dives_from, struct dive_table *
void add_imported_dives(struct dive_table *import_table, struct trip_table *import_trip_table, struct dive_site_table *import_sites_table, int flags)
{
int i, idx;
- struct dive_table dives_to_add = { 0 };
- struct dive_table dives_to_remove = { 0 };
- struct trip_table trips_to_add = { 0 };
- struct dive_site_table dive_sites_to_add = { 0 };
+ struct dive_table dives_to_add = empty_dive_table;
+ struct dive_table dives_to_remove = empty_dive_table;
+ struct trip_table trips_to_add = empty_trip_table;
+ struct dive_site_table dive_sites_to_add = empty_dive_site_table;
/* Process imported dives and generate lists of dives
* to-be-added and to-be-removed */
@@ -1121,7 +1121,7 @@ void process_imported_dives(struct dive_table *import_table, struct trip_table *
/* If the caller didn't pass an import_trip_table because all
* dives are tripless, provide a local table. This may be
* necessary if the trips are autogrouped */
- struct trip_table local_trip_table = { 0 };
+ struct trip_table local_trip_table = empty_trip_table;
if (!import_trip_table)
import_trip_table = &local_trip_table;
diff --git a/core/divesite.h b/core/divesite.h
index d6ec4e51d..30daf3bea 100644
--- a/core/divesite.h
+++ b/core/divesite.h
@@ -31,6 +31,8 @@ typedef struct dive_site_table {
struct dive_site **dive_sites;
} dive_site_table_t;
+static const dive_site_table_t empty_dive_site_table = { 0, 0, (struct dive_site **)0 };
+
extern struct dive_site_table dive_site_table;
static inline struct dive_site *get_dive_site(int nr, struct dive_site_table *ds_table)
diff --git a/core/trip.h b/core/trip.h
index 51f371589..3a8a2feb7 100644
--- a/core/trip.h
+++ b/core/trip.h
@@ -24,6 +24,8 @@ typedef struct trip_table {
struct dive_trip **trips;
} trip_table_t;
+static const trip_table_t empty_trip_table = { 0, 0, (struct dive_trip **)0 };
+
extern void add_dive_to_trip(struct dive *, dive_trip_t *);
extern struct dive_trip *unregister_dive_from_trip(struct dive *dive);
extern void remove_dive_from_trip(struct dive *dive, struct trip_table *trip_table_arg);