+/*
+ * Release memory for Valgrind.
+ */
+static void cleanup(struct ui_psensor *ui)
+{
+ pmutex_lock(&ui->sensors_mutex);
+
+ log_debug("Cleanup...");
+
+ nvidia_cleanup();
+ amd_cleanup();
+ rsensor_cleanup();
+
+ psensor_list_free(ui->sensors);
+ ui->sensors = NULL;
+
+ ui_appindicator_cleanup();
+
+ ui_status_cleanup();
+
+ pmutex_unlock(&ui->sensors_mutex);
+
+ config_cleanup();
+
+ log_debug("Cleanup done, closing log");
+}
+
+/*
+ * Creates the list of sensors.
+ *
+ * 'url': remote psensor server url, null for local monitoring.
+ */
+static struct psensor **create_sensors_list(const char *url)
+{
+ struct psensor **sensors;
+
+ if (url) {
+ if (rsensor_is_supported()) {
+ rsensor_init();
+ sensors = get_remote_sensors(url, 600);
+ } else {
+ log_err(_("Psensor has not been compiled with remote "
+ "sensor support."));
+ exit(EXIT_FAILURE);
+ }
+ } else {
+ sensors = malloc(sizeof(struct psensor *));
+ *sensors = NULL;
+
+ if (config_is_lmsensor_enabled())
+ lmsensor_psensor_list_append(&sensors, 600);
+
+ if (config_is_hddtemp_enabled())
+ hddtemp_psensor_list_append(&sensors, 600);
+
+ if (config_is_libatasmart_enabled())
+ atasmart_psensor_list_append(&sensors, 600);
+
+ if (config_is_nvctrl_enabled())
+ nvidia_psensor_list_append(&sensors, 600);
+
+ if (config_is_atiadlsdk_enabled())
+ amd_psensor_list_append(&sensors, 600);
+
+ if (config_is_gtop2_enabled())
+ gtop2_psensor_list_append(&sensors, 600);
+
+ if (config_is_udisks2_enabled())
+ udisks2_psensor_list_append(&sensors, 600);
+ }
+
+ associate_preferences(sensors);
+
+ return sensors;
+}
+