mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Cleanup: unconstify results of two functions
get_dive_date_c_string() and get_current_date() return copied strings. Make this explicit by returning non-const pointers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
44bcc5a307
commit
f7b2355ced
5 changed files with 12 additions and 12 deletions
|
@ -1016,7 +1016,7 @@ extern void set_userid(const char *user_id);
|
|||
extern void set_informational_units(const char *units);
|
||||
extern void set_git_prefs(const char *prefs);
|
||||
|
||||
extern const char *get_dive_date_c_string(timestamp_t when);
|
||||
extern char *get_dive_date_c_string(timestamp_t when);
|
||||
extern void update_setpoint_events(struct dive *dive, struct divecomputer *dc);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -618,9 +618,9 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, device_data_t *devda
|
|||
}
|
||||
|
||||
// Parse the divetime.
|
||||
const char *date_string = get_dive_date_c_string(dive->when);
|
||||
char *date_string = get_dive_date_c_string(dive->when);
|
||||
dev_info(devdata, translate("gettextFromC", "Dive %d: %s"), import_dive_number, date_string);
|
||||
free((void *)date_string);
|
||||
free(date_string);
|
||||
|
||||
unsigned int divetime = 0;
|
||||
rc = dc_parser_get_field(parser, DC_FIELD_DIVETIME, 0, &divetime);
|
||||
|
@ -802,9 +802,9 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
|
||||
/* If we already saw this dive, abort. */
|
||||
if (!devdata->force_download && find_dive(&dive->dc)) {
|
||||
const char *date_string = get_dive_date_c_string(dive->when);
|
||||
char *date_string = get_dive_date_c_string(dive->when);
|
||||
dev_info(devdata, translate("gettextFromC", "Already downloaded dive at %s"), date_string);
|
||||
free((void *)date_string);
|
||||
free(date_string);
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,15 +137,15 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
dive->notes = strdup(buffer);
|
||||
goto finished;
|
||||
} else if (diveplan->surface_interval >= 48 * 60 *60) {
|
||||
const char *current_date = get_current_date();
|
||||
char *current_date = get_current_date();
|
||||
len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s (%s) %s %s</b><br>",
|
||||
translate("gettextFromC", "Subsurface"),
|
||||
subsurface_canonical_version(),
|
||||
translate("gettextFromC", "dive plan</b> created on"),
|
||||
current_date);
|
||||
free((void *)current_date);
|
||||
free(current_date);
|
||||
} else {
|
||||
const char *current_date = get_current_date();
|
||||
char *current_date = get_current_date();
|
||||
len += snprintf_loc(buffer + len, sz_buffer - len, "<div><b>%s (%s) %s %d:%02d) %s %s<br>",
|
||||
translate("gettextFromC", "Subsurface"),
|
||||
subsurface_canonical_version(),
|
||||
|
@ -153,7 +153,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
FRACTION(diveplan->surface_interval / 60, 60),
|
||||
translate("gettextFromC", "created on"),
|
||||
current_date);
|
||||
free((void *)current_date);
|
||||
free(current_date);
|
||||
}
|
||||
|
||||
if (prefs.display_variations && decoMode() != RECREATIONAL)
|
||||
|
|
|
@ -976,13 +976,13 @@ QString get_short_dive_date_string(timestamp_t when)
|
|||
return loc.toString(ts.toUTC(), QString(prefs.date_format_short) + " " + prefs.time_format);
|
||||
}
|
||||
|
||||
const char *get_dive_date_c_string(timestamp_t when)
|
||||
char *get_dive_date_c_string(timestamp_t when)
|
||||
{
|
||||
QString text = get_dive_date_string(when);
|
||||
return copy_qstring(text);
|
||||
}
|
||||
|
||||
extern "C" const char *get_current_date()
|
||||
extern "C" char *get_current_date()
|
||||
{
|
||||
QDateTime ts(QDateTime::currentDateTime());;
|
||||
QString current_date;
|
||||
|
|
|
@ -79,7 +79,7 @@ char *picturedir_string();
|
|||
const char *subsurface_user_agent();
|
||||
enum deco_mode decoMode();
|
||||
int parse_seabear_header(const char *filename, char **params, int pnr);
|
||||
const char *get_current_date();
|
||||
char *get_current_date();
|
||||
double cache_value(int tissue, int timestep, enum inertgas gas);
|
||||
void cache_insert(int tissue, int timestep, enum inertgas gas, double value);
|
||||
void print_qt_versions();
|
||||
|
|
Loading…
Reference in a new issue