mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
core: use free_dive() to free dive
One would think that calling free() on a dive structure, as the code did in some places, would lead to a memory leak. (Insert rant about C memory management.) Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
252761498a
commit
1c00f9f233
5 changed files with 7 additions and 14 deletions
|
@ -609,7 +609,7 @@ int parse_txt_file(const char *filename, const char *csv, struct dive_table *tab
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (readfile(csv, &memcsv) < 0) {
|
if (readfile(csv, &memcsv) < 0) {
|
||||||
free(dive);
|
free_dive(dive);
|
||||||
return report_error(translate("gettextFromC", "Poseidon import failed: unable to read '%s'"), csv);
|
return report_error(translate("gettextFromC", "Poseidon import failed: unable to read '%s'"), csv);
|
||||||
}
|
}
|
||||||
lineptr = memcsv.buffer;
|
lineptr = memcsv.buffer;
|
||||||
|
|
|
@ -821,7 +821,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
||||||
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);
|
dev_info(devdata, translate("gettextFromC", "Already downloaded dive at %s"), date_string);
|
||||||
free(date_string);
|
free(date_string);
|
||||||
free(dive);
|
free_dive(dive);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,7 +844,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
||||||
|
|
||||||
error_exit:
|
error_exit:
|
||||||
dc_parser_destroy(parser);
|
dc_parser_destroy(parser);
|
||||||
free(dive);
|
free_dive(dive);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,7 +433,7 @@ static void parse_dives(int log_version, const unsigned char *buf, unsigned int
|
||||||
//DEBUG save_dives("/tmp/test.xml");
|
//DEBUG save_dives("/tmp/test.xml");
|
||||||
|
|
||||||
// if we bailed out of the loop, the dive hasn't been recorded and dive hasn't been set to NULL
|
// if we bailed out of the loop, the dive hasn't been recorded and dive hasn't been set to NULL
|
||||||
free(dive);
|
free_dive(dive);
|
||||||
}
|
}
|
||||||
|
|
||||||
int try_to_open_liquivision(const char *filename, struct memblock *mem, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites)
|
int try_to_open_liquivision(const char *filename, struct memblock *mem, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites)
|
||||||
|
|
|
@ -857,14 +857,7 @@ static bool uemis_delete_dive(device_data_t *devdata, uint32_t diveid)
|
||||||
}
|
}
|
||||||
if (dive) {
|
if (dive) {
|
||||||
devdata->download_table->dives[--devdata->download_table->nr] = NULL;
|
devdata->download_table->dives[--devdata->download_table->nr] = NULL;
|
||||||
|
free_dive(dive);
|
||||||
free(dive->dc.sample);
|
|
||||||
free((void *)dive->notes);
|
|
||||||
free((void *)dive->diveguide);
|
|
||||||
free((void *)dive->buddy);
|
|
||||||
free((void *)dive->suit);
|
|
||||||
taglist_free(dive->tag_list);
|
|
||||||
free(dive);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1023,7 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
|
||||||
if (dive->dc.diveid) {
|
if (dive->dc.diveid) {
|
||||||
record_dive_to_table(dive, devdata->download_table);
|
record_dive_to_table(dive, devdata->download_table);
|
||||||
} else { /* partial dive */
|
} else { /* partial dive */
|
||||||
free(dive);
|
free_dive(dive);
|
||||||
free(buf);
|
free(buf);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1272,7 +1272,7 @@ finish:
|
||||||
free(original_plan);
|
free(original_plan);
|
||||||
free(save);
|
free(save);
|
||||||
free(cache);
|
free(cache);
|
||||||
free(dive);
|
free_dive(dive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerPointsModel::computeVariationsDone(QString variations)
|
void DivePlannerPointsModel::computeVariationsDone(QString variations)
|
||||||
|
|
Loading…
Reference in a new issue