mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: fix printGPSCoords signature and leaks
The printGPSCoords() function returns a copied C-style string. Since the owndership is transferred to the caller, the correct return type is "char *" instead of "const char *". Thus a number of casts when calling free can be removed. Moreover a number of callers didn't free the string and thus were leaking memory. Fix them. Ultimately we might want two versions of the function: one for QString, one for C-style strings. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
8facd937f8
commit
04593e8ec4
11 changed files with 31 additions and 21 deletions
|
@ -164,10 +164,10 @@ static void parse_dive_gps(char *line, struct membuffer *str, void *_dive)
|
|||
dive->dive_site = ds;
|
||||
} else {
|
||||
if (dive_site_has_gps_location(ds) && !same_location(&ds->location, &location)) {
|
||||
const char *coords = printGPSCoords(&location);
|
||||
char *coords = printGPSCoords(&location);
|
||||
// we have a dive site that already has GPS coordinates
|
||||
ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple GPS locations for this dive site; also %s\n"), coords);
|
||||
free((void *)coords);
|
||||
free(coords);
|
||||
}
|
||||
ds->location = location;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue