From cf4d32c6e8bd60b5e825535702f3e2701b40716b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 13 Oct 2018 22:32:53 +0200 Subject: Cleanup: constify get_dive_gas() and get_dive_gas_string() There's no reason for the dive input-parameter being non-const. Signed-off-by: Berthold Stoeger --- core/divelist.c | 9 +++++---- core/divelist.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/divelist.c b/core/divelist.c index 88a4de152..65c3298c8 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -8,7 +8,8 @@ * dive_trip_t *dive_trip_list; * unsigned int amount_selected; * void dump_selection(void) - * void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p) + * void get_dive_gas(const struct dive *dive, int *o2_p, int *he_p, int *o2low_p) + * char *get_dive_gas_string(const struct dive *dive) * int total_weight(const struct dive *dive) * int get_divenr(const struct dive *dive) * int get_divesite_idx(const struct dive_site *ds) @@ -104,14 +105,14 @@ void set_autogroup(bool value) * - Nitrox trumps air (even if hypoxic) * These are the same rules as the inter-dive sorting rules. */ -void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2max_p) +void get_dive_gas(const struct dive *dive, int *o2_p, int *he_p, int *o2max_p) { int i; int maxo2 = -1, maxhe = -1, mino2 = 1000; for (i = 0; i < MAX_CYLINDERS; i++) { - cylinder_t *cyl = dive->cylinder + i; + const cylinder_t *cyl = dive->cylinder + i; int o2 = get_o2(cyl->gasmix); int he = get_he(cyl->gasmix); @@ -658,7 +659,7 @@ void update_cylinder_related_info(struct dive *dive) #define UTF8_ELLIPSIS "\xE2\x80\xA6" /* callers needs to free the string */ -char *get_dive_gas_string(struct dive *dive) +char *get_dive_gas_string(const struct dive *dive) { int o2, he, o2max; char *buffer = malloc(MAX_GAS_STRING); diff --git a/core/divelist.h b/core/divelist.h index 681934a0c..0f944fe34 100644 --- a/core/divelist.h +++ b/core/divelist.h @@ -20,10 +20,10 @@ extern int init_decompression(struct deco_state *ds, struct dive *dive); /* divelist core logic functions */ extern void process_loaded_dives(); extern void process_imported_dives(struct dive_table *import_table, bool prefer_imported, bool downloaded); -extern char *get_dive_gas_string(struct dive *dive); +extern char *get_dive_gas_string(const struct dive *dive); struct dive **grow_dive_table(struct dive_table *table); -extern void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p); +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 int get_divesite_idx(const struct dive_site *ds); extern struct dive_trip *unregister_dive_from_trip(struct dive *dive, short was_autogen); -- cgit v1.2.3-70-g09d2