From e740aecaea148878dd9b342a2dd55f963839bae7 Mon Sep 17 00:00:00 2001 From: Philippe Pepiot Date: Thu, 27 Aug 2009 08:10:55 +0200 Subject: [PATCH] Config: Wrapper for conf_*_section Pointer returned by get_sec() wasn't free() --- src/config.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/config.c b/src/config.c index 87aaf5c..7ff5289 100644 --- a/src/config.c +++ b/src/config.c @@ -32,6 +32,9 @@ #include "wmfs.h" +/* local function definition */ +static void conf_section(void (*)(char*), char *, char *); + func_name_list_t tmp_func_list[] = { {"spawn", uicb_spawn }, @@ -531,15 +534,15 @@ init_conf(void) func_list = emalloc(LEN(tmp_func_list), sizeof(func_name_list_t)); memcpy(func_list, tmp_func_list, LEN(tmp_func_list) * sizeof(func_name_list_t)); - conf_misc_section(get_sec(file, "misc")); - conf_bar_section(get_sec(file, "bar")); - conf_root_section(get_sec(file, "root")); - conf_client_section(get_sec(file, "client")); - conf_layout_section(get_sec(file, "layouts")); - conf_tag_section(get_sec(file, "tags")); - conf_menu_section(get_sec(file, "menu")); - conf_launcher_section(get_sec(file, "launcher")); - conf_keybind_section(get_sec(file, "keys")); + conf_section(conf_misc_section, file, "misc"); + conf_section(conf_bar_section, file, "bar"); + conf_section(conf_root_section, file, "root"); + conf_section(conf_client_section, file, "client"); + conf_section(conf_layout_section, file, "layouts"); + conf_section(conf_tag_section, file, "tags"); + conf_section(conf_menu_section, file, "menu"); + conf_section(conf_launcher_section, file, "launcher"); + conf_section(conf_keybind_section, file, "keys"); free(file); @@ -547,5 +550,18 @@ init_conf(void) } +/** Simple wrapper for calling functions and free pointer + */ +static void +conf_section(void (*func)(char*), char *src, char *name) +{ + char *sec; + + sec = get_sec(src, name); + func(sec); + free(sec); + + return; +}