summaryrefslogtreecommitdiffstats
path: root/map-widget
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-24 21:50:01 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-03-24 21:57:13 -0700
commit04593e8ec4bac2606dec54605c72a6a49cc83f9b (patch)
tree030da73608ad9bf1653b5018404b3a5514e6c7bd /map-widget
parent8facd937f86d913d94275abb80bfa4d2b181bbc6 (diff)
downloadsubsurface-04593e8ec4bac2606dec54605c72a6a49cc83f9b.tar.gz
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>
Diffstat (limited to 'map-widget')
-rw-r--r--map-widget/qmlmapwidgethelper.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp
index a7fb86d9b..61b8f0abe 100644
--- a/map-widget/qmlmapwidgethelper.cpp
+++ b/map-widget/qmlmapwidgethelper.cpp
@@ -246,10 +246,10 @@ void MapWidgetHelper::copyToClipboardCoordinates(QGeoCoordinate coord, bool form
bool savep = prefs.coordinates_traditional;
prefs.coordinates_traditional = formatTraditional;
location_t location = mk_location(coord);
- const char *coordinates = printGPSCoords(&location);
+ char *coordinates = printGPSCoords(&location);
QApplication::clipboard()->setText(QString(coordinates), QClipboard::Clipboard);
- free((void *)coordinates);
+ free(coordinates);
prefs.coordinates_traditional = savep;
}