Do not check for null before free.

C specs says that we can safelly free a NULL pointer, so there's no reason
to check if it's null before freeing it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-05-12 14:58:15 -03:00 committed by Dirk Hohndel
parent e0c0ac5d5c
commit c86d055db7
8 changed files with 28 additions and 44 deletions

View file

@ -243,7 +243,7 @@ void DownloadFromDCWidget::fill_computer_list()
if (!productList["Uemis"].contains("Zurich"))
productList["Uemis"].push_back("Zurich");
descriptorLookup[QString("UemisZurich")] = (dc_descriptor_t *)mydescriptor;
descriptorLookup["UemisZurich"] = (dc_descriptor_t *)mydescriptor;
qSort(vendorList);
}
@ -322,8 +322,7 @@ void DownloadFromDCWidget::pickLogFile()
logFile = QFileDialog::getSaveFileName(this, tr("Choose file for divecomputer download logfile"),
filename, tr("Log files (*.log)"));
if (!logFile.isEmpty()) {
if (logfile_name)
free(logfile_name);
free(logfile_name);
logfile_name = strdup(logFile.toUtf8().data());
}
}
@ -351,8 +350,7 @@ void DownloadFromDCWidget::pickDumpFile()
dumpFile = QFileDialog::getSaveFileName(this, tr("Choose file for divecomputer binary dump file"),
filename, tr("Dump files (*.bin)"));
if (!dumpFile.isEmpty()) {
if (dumpfile_name)
free(dumpfile_name);
free(dumpfile_name);
dumpfile_name = strdup(dumpFile.toUtf8().data());
}
}

View file

@ -245,10 +245,9 @@ void MainWindow::on_actionClose_triggered()
/* clear the selection and the statistics */
selected_dive = -1;
if (existing_filename) {
free((void *)existing_filename);
existing_filename = NULL;
}
free((void *)existing_filename);
existing_filename = NULL;
cleanUpEmpty();
mark_divelist_changed(false);