diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2011-01-20 18:34:08 +0100 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2011-01-20 18:34:08 +0100 |
commit | d7d62ea5ee19f5cad52dcfb2f2a49d8d36fa1228 (patch) | |
tree | acceeed18451fd1ff982f3108ace88b77df82c18 /src | |
parent | 0e7e088d6faec43234e1f967b6e1e853cb9fedf1 (diff) | |
download | abrt-d7d62ea5ee19f5cad52dcfb2f2a49d8d36fa1228.tar.gz abrt-d7d62ea5ee19f5cad52dcfb2f2a49d8d36fa1228.tar.xz abrt-d7d62ea5ee19f5cad52dcfb2f2a49d8d36fa1228.zip |
introduce and use new helper function list_free_with_free
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/cli/dbus.h | 1 | ||||
-rw-r--r-- | src/cli/report.cpp | 2 | ||||
-rw-r--r-- | src/daemon/Daemon.cpp | 5 | ||||
-rw-r--r-- | src/daemon/Settings.cpp | 24 | ||||
-rw-r--r-- | src/daemon/Settings.h | 6 | ||||
-rw-r--r-- | src/daemon/abrt-action-save-package-data.c | 4 | ||||
-rw-r--r-- | src/daemon/rpm.c | 1 | ||||
-rw-r--r-- | src/include/abrt_types.h | 2 | ||||
-rw-r--r-- | src/include/abrtlib.h | 7 | ||||
-rw-r--r-- | src/lib/Makefile.am | 1 | ||||
-rw-r--r-- | src/lib/abrt_dbus.c | 1 | ||||
-rw-r--r-- | src/lib/abrt_dbus.h | 1 | ||||
-rw-r--r-- | src/lib/glib_support.c | 26 | ||||
-rw-r--r-- | src/plugins/abrt-dump-oops.c | 4 |
14 files changed, 50 insertions, 35 deletions
diff --git a/src/cli/dbus.h b/src/cli/dbus.h index 62ce6fca..e2e763c2 100644 --- a/src/cli/dbus.h +++ b/src/cli/dbus.h @@ -18,7 +18,6 @@ #ifndef ABRT_CLI_DBUS_H #define ABRT_CLI_DBUS_H -#include <glib.h> #include "abrt_dbus.h" #include "abrt_crash_data.h" diff --git a/src/cli/report.cpp b/src/cli/report.cpp index 8b8f9cc6..d0a74955 100644 --- a/src/cli/report.cpp +++ b/src/cli/report.cpp @@ -15,8 +15,6 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <termios.h> -#include <glib.h> #include "report.h" #include "run-command.h" #include "dbus.h" diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp index eddcd766..8d972a9a 100644 --- a/src/daemon/Daemon.cpp +++ b/src/daemon/Daemon.cpp @@ -25,7 +25,6 @@ #include <string> #include <sys/inotify.h> #include <sys/ioctl.h> /* ioctl(FIONREAD) */ -#include <glib.h> #include "abrtlib.h" #include "comm_layer_inner.h" #include "Settings.h" @@ -633,7 +632,7 @@ int main(int argc, char** argv) init_daemon_logging(&watcher); VERB1 log("Loading settings"); - if (LoadSettings() != 0) + if (load_settings() != 0) throw 1; sanitize_dump_dir_rights(); @@ -759,7 +758,7 @@ int main(int argc, char** argv) if (pMainloop) g_main_loop_unref(pMainloop); - settings_free(); + free_settings(); if (log_scanner_pid > 0) { diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp index b8f8751e..ff9062fc 100644 --- a/src/daemon/Settings.cpp +++ b/src/daemon/Settings.cpp @@ -31,7 +31,7 @@ */ /* Static data */ -/* Filled by LoadSettings() */ +/* Filled by load_settings() */ /* map["name"] = "value" strings from [ Common ] section. * If the same name found on more than one line, @@ -258,7 +258,7 @@ static int ReadConfigurationFromFile(FILE *fp) } /* abrt daemon loads .conf file */ -int LoadSettings() +int load_settings() { int err = 0; @@ -311,26 +311,20 @@ map_abrt_settings_t GetSettings() // } //} -void settings_free() +void free_settings() { - for (GList *li = g_settings_setOpenGPGPublicKeys; li != NULL; li = g_list_next(li)) - free((char*)li->data); - - g_list_free(g_settings_setOpenGPGPublicKeys); + list_free_with_free(g_settings_setOpenGPGPublicKeys); g_settings_setOpenGPGPublicKeys = NULL; - for (GList *li = g_settings_setBlackListedPkgs; li != NULL; li = g_list_next(li)) - free((char*)li->data); - - g_list_free(g_settings_setBlackListedPkgs); + list_free_with_free(g_settings_setBlackListedPkgs); g_settings_setBlackListedPkgs = NULL; - for (GList *li = g_settings_setBlackListedPaths; li != NULL; li = g_list_next(li)) - free((char*)li->data); - - g_list_free(g_settings_setBlackListedPaths); + list_free_with_free(g_settings_setBlackListedPaths); g_settings_setBlackListedPaths = NULL; free(g_settings_sWatchCrashdumpArchiveDir); g_settings_sWatchCrashdumpArchiveDir = NULL; + + free(g_settings_sLogScanners); + g_settings_sLogScanners = NULL; } diff --git a/src/daemon/Settings.h b/src/daemon/Settings.h index 6940732f..dce6407d 100644 --- a/src/daemon/Settings.h +++ b/src/daemon/Settings.h @@ -20,7 +20,6 @@ #define SETTINGS_H_ #include "abrt_types.h" -#include <glib.h> #ifdef __cplusplus @@ -43,9 +42,8 @@ extern char * g_settings_sWatchCrashdumpArchiveDir; extern char * g_settings_sLogScanners; -int LoadSettings(); - -void settings_free(); +int load_settings(); +void free_settings(); #ifdef __cplusplus } diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c index cb880bd3..d912dec4 100644 --- a/src/daemon/abrt-action-save-package-data.c +++ b/src/daemon/abrt-action-save-package-data.c @@ -304,8 +304,8 @@ int main(int argc, char **argv) } VERB1 log("Loading settings"); - if (LoadSettings() != 0) - return 1; /* syntax error (looged already by LoadSettings) */ + if (load_settings() != 0) + return 1; /* syntax error (logged already by load_settings) */ VERB1 log("Initializing rpm library"); rpm_init(); diff --git a/src/daemon/rpm.c b/src/daemon/rpm.c index 4665273f..25f95e8c 100644 --- a/src/daemon/rpm.c +++ b/src/daemon/rpm.c @@ -16,7 +16,6 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <glib.h> #include "abrtlib.h" #include "rpm.h" diff --git a/src/include/abrt_types.h b/src/include/abrt_types.h index 858c0c79..200946e1 100644 --- a/src/include/abrt_types.h +++ b/src/include/abrt_types.h @@ -19,8 +19,6 @@ #ifndef ABRT_TYPES_H_ #define ABRT_TYPES_H_ -#include <glib.h> - #ifdef __cplusplus extern "C" { #endif diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 0c0d4be4..4ad2f6fc 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -42,6 +42,7 @@ #ifdef __cplusplus # include <string> #endif +#include <glib.h> #ifdef HAVE_CONFIG_H # include "config.h" @@ -184,6 +185,12 @@ char *run_in_shell_and_save_output(int flags, /* Random utility functions */ +/* Frees every element'd data using free(), + * then frees list itself using g_list_free(list): + */ +#define list_free_with_free abrt_list_free_with_free +void list_free_with_free(GList *list); + #define get_dirsize abrt_get_dirsize double get_dirsize(const char *pPath); #define get_dirsize_find_largest_dir abrt_get_dirsize_find_largest_dir diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 20fbd4ed..ce06795a 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -32,6 +32,7 @@ libreport_la_SOURCES = \ dirsize.c \ dump_dir.c \ get_cmdline.c \ + glib_support.c \ daemon_is_ok.c \ load_plugin_settings.c \ make_descr.c \ diff --git a/src/lib/abrt_dbus.c b/src/lib/abrt_dbus.c index 69ac1241..d1717636 100644 --- a/src/lib/abrt_dbus.c +++ b/src/lib/abrt_dbus.c @@ -17,7 +17,6 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include <dbus/dbus.h> -#include <glib.h> #include "abrtlib.h" #include "abrt_dbus.h" diff --git a/src/lib/abrt_dbus.h b/src/lib/abrt_dbus.h index d8cc3aa8..2723555c 100644 --- a/src/lib/abrt_dbus.h +++ b/src/lib/abrt_dbus.h @@ -20,7 +20,6 @@ #define ABRT_DBUS_H #include <dbus/dbus.h> -#include <glib.h> #include "abrtlib.h" diff --git a/src/lib/glib_support.c b/src/lib/glib_support.c new file mode 100644 index 00000000..feb4c18b --- /dev/null +++ b/src/lib/glib_support.c @@ -0,0 +1,26 @@ +/* + Copyright (C) 2011 ABRT team + Copyright (C) 2011 RedHat Inc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#include "abrtlib.h" + +void list_free_with_free(GList *list) +{ + for (GList *li = list; li; li = g_list_next(li)) + free(li->data); + g_list_free(list); +} diff --git a/src/plugins/abrt-dump-oops.c b/src/plugins/abrt-dump-oops.c index ad222edd..07e2618b 100644 --- a/src/plugins/abrt-dump-oops.c +++ b/src/plugins/abrt-dump-oops.c @@ -675,9 +675,7 @@ int main(int argc, char **argv) log("%d errors while dumping oopses", errors); } } - for (GList *li = oops_list; li; li = g_list_next(li)) - free((char*)li->data); - g_list_free(oops_list); + list_free_with_free(oops_list); oops_list = NULL; /* Done if no -w */ |