diff options
-rw-r--r-- | dive.c | 3 | ||||
-rw-r--r-- | divecomputer.cpp | 11 | ||||
-rw-r--r-- | divelist.c | 24 | ||||
-rw-r--r-- | profile.c | 4 | ||||
-rw-r--r-- | qt-gui.cpp | 6 | ||||
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 8 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 7 | ||||
-rw-r--r-- | statistics.c | 9 |
8 files changed, 28 insertions, 44 deletions
@@ -1758,8 +1758,7 @@ static void free_events(struct event *ev) static void free_dc(struct divecomputer *dc) { free(dc->sample); - if (dc->model) - free((void *)dc->model); + free((void *)dc->model); free_events(dc->events); free(dc); } diff --git a/divecomputer.cpp b/divecomputer.cpp index c02bbea55..6044f1aa6 100644 --- a/divecomputer.cpp +++ b/divecomputer.cpp @@ -130,10 +130,9 @@ void set_default_dive_computer(const char *vendor, const char *product) return; if (is_default_dive_computer(vendor, product)) return; - if (default_dive_computer_vendor) - free((void *)default_dive_computer_vendor); - if (default_dive_computer_product) - free((void *)default_dive_computer_product); + + free((void *)default_dive_computer_vendor); + free((void *)default_dive_computer_product); default_dive_computer_vendor = strdup(vendor); default_dive_computer_product = strdup(product); s.beginGroup("DiveComputer"); @@ -150,8 +149,8 @@ void set_default_dive_computer_device(const char *name) return; if (is_default_dive_computer_device(name)) return; - if (default_dive_computer_device) - free((void *)default_dive_computer_device); + + free((void *)default_dive_computer_device); default_dive_computer_device = strdup(name); s.beginGroup("DiveComputer"); s.setValue("dive_computer_device", name); diff --git a/divelist.c b/divelist.c index f8d3d70d3..b19971087 100644 --- a/divelist.c +++ b/divelist.c @@ -566,10 +566,8 @@ static void delete_trip(dive_trip_t *trip) } /* .. and free it */ - if (trip->location) - free(trip->location); - if (trip->notes) - free(trip->notes); + free(trip->location); + free(trip->notes); free(trip); } @@ -703,18 +701,12 @@ void delete_single_dive(int idx) dive_table.dives[--dive_table.nr] = NULL; /* free all allocations */ free(dive->dc.sample); - if (dive->location) - free((void *)dive->location); - if (dive->notes) - free((void *)dive->notes); - if (dive->divemaster) - free((void *)dive->divemaster); - if (dive->buddy) - free((void *)dive->buddy); - if (dive->suit) - free((void *)dive->suit); - if (dive->tag_list) - taglist_free(dive->tag_list); + free((void *)dive->location); + free((void *)dive->notes); + free((void *)dive->divemaster); + free((void *)dive->buddy); + free((void *)dive->suit); + taglist_free(dive->tag_list); free(dive); } @@ -1184,8 +1184,8 @@ void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plo { int o2, he, o2low; init_decompression(dive); - if (last_pi_entry_new) /* Create the new plot data */ - free((void *)last_pi_entry_new); + /* Create the new plot data */ + free((void *)last_pi_entry_new); get_dive_gas(dive, &o2, &he, &o2low); if (he > 0) { pi->dive_type = TRIMIX; diff --git a/qt-gui.cpp b/qt-gui.cpp index 868389eab..9d6dde45f 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -165,10 +165,8 @@ void exit_ui(void) { delete window; delete application; - if (existing_filename) - free((void *)existing_filename); - if (default_dive_computer_device) - free((void *)default_dive_computer_device); + free((void *)existing_filename); + free((void *)default_dive_computer_device); } void set_filename(const char *filename, bool force) diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index bc829249c..17c2a4eaa 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -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()); } } diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 769f486de..709693c30 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -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); diff --git a/statistics.c b/statistics.c index ad5a95d06..2a96efb81 100644 --- a/statistics.c +++ b/statistics.c @@ -114,11 +114,10 @@ void process_all_dives(struct dive *dive, struct dive **prev_dive) * case (one dive per year or all dives during * one month) for yearly and monthly statistics*/ - if (stats_yearly != NULL) { - free(stats_yearly); - free(stats_monthly); - free(stats_by_trip); - } + free(stats_yearly); + free(stats_monthly); + free(stats_by_trip); + size = sizeof(stats_t) * (dive_table.nr + 1); stats_yearly = malloc(size); stats_monthly = malloc(size); |