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:
committed by
Dirk Hohndel
parent
8facd937f8
commit
04593e8ec4
@@ -1602,9 +1602,12 @@ QString QMLManager::getGpsFromSiteName(const QString& siteName)
|
||||
struct dive_site *ds;
|
||||
|
||||
ds = get_dive_site_by_name(qPrintable(siteName));
|
||||
if (ds)
|
||||
return QString(printGPSCoords(&ds->location));
|
||||
return QString();
|
||||
if (!ds)
|
||||
return QString();
|
||||
char *gps = printGPSCoords(&ds->location);
|
||||
QString res = gps;
|
||||
free(gps);
|
||||
return res;
|
||||
}
|
||||
|
||||
void QMLManager::setNotificationText(QString text)
|
||||
|
||||
Reference in New Issue
Block a user