diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-01-08 21:25:02 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-10 02:37:03 +0900 |
commit | e1cd055111cc4f7e11454b3726741f9f8a55d850 (patch) | |
tree | bb391d65743da3285367ec1f1803925978db6877 /core | |
parent | 70cabb968c481e566e8249465f153e05e6dc0347 (diff) | |
download | subsurface-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.h | 2 | ||||
-rw-r--r-- | core/divelist.c | 10 | ||||
-rw-r--r-- | core/divesite.h | 2 | ||||
-rw-r--r-- | core/trip.h | 2 |
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); |