diff --git a/src/config.c b/src/config.c index 0b7606e..e9760bf 100644 --- a/src/config.c +++ b/src/config.c @@ -44,7 +44,6 @@ cfg_t *cfg_layouts; cfg_t *cfg_tags; cfg_t *cfg_keys; cfg_t *cfgtmp; -Alias *confalias; static cfg_opt_t misc_opts[] = { @@ -301,9 +300,11 @@ alias_to_str(char *conf_choice) if(!conf_choice) return 0; - for(i = 0; confalias[i].name; i++) - if(!strcmp(conf_choice, confalias[i].name)) - tmpchar = confalias[i].content; + if(conf.alias) + for(i = 0; conf.alias[i].name; i++) + if(!strcmp(conf_choice, conf.alias[i].name)) + tmpchar = conf.alias[i].content; + if(tmpchar) return strdup(tmpchar); else @@ -368,13 +369,13 @@ init_conf(void) /* alias */ if(cfg_size(cfg_alias, "alias")) { - confalias = emalloc(cfg_size(cfg_alias, "alias"), sizeof(Alias)); + conf.alias = emalloc(cfg_size(cfg_alias, "alias"), sizeof(Alias)); for(i = 0; i < cfg_size(cfg_alias, "alias"); ++i) { - cfgtmp = cfg_getnsec(cfg_alias, "alias", i); - confalias[i].name = strdup(cfg_title(cfgtmp)); - confalias[i].content = strdup(cfg_getstr(cfgtmp, "content")); + cfgtmp = cfg_getnsec(cfg_alias, "alias", i); + conf.alias[i].name = strdup(cfg_title(cfgtmp)); + conf.alias[i].content = strdup(cfg_getstr(cfgtmp, "content")); } } @@ -527,7 +528,6 @@ init_conf(void) ? NULL : strdup(alias_to_str(cfg_getstr(cfgtmp, "cmd")))); } cfg_free(cfg); - free(confalias); return; } diff --git a/src/structs.h b/src/structs.h index 3e7ce3b..2593fe2 100644 --- a/src/structs.h +++ b/src/structs.h @@ -156,9 +156,17 @@ typedef struct Layout layout; } Tag; +/* Alias struct */ +typedef struct +{ + char *name; + char *content; +} Alias; + /* Configuration structure */ typedef struct { + /* Misc option */ char *font; bool raisefocus; bool raiseswitch; @@ -203,6 +211,7 @@ typedef struct MouseBinding *mouse; int nmouse; } titlebar; + Alias *alias; Tag tag[MAXTAG]; Layout layout[NUM_OF_LAYOUT]; int *ntag; @@ -231,10 +240,4 @@ typedef struct uint button; } name_to_uint_t; -typedef struct -{ - char *name; - char *content; -} Alias; - #endif /* STRUCTS_H */ diff --git a/src/wmfs.c b/src/wmfs.c index 32a8738..eaedae3 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -111,6 +111,8 @@ quit(void) free(conf.titlebar.mouse); free(conf.client.mouse); free(conf.root.mouse); + if(conf.alias) + free(conf.alias); XSync(dpy, False); return; diff --git a/src/wmfs.h b/src/wmfs.h index 7f4ff24..572ce4d 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -257,7 +257,6 @@ Client *sel; /* Other */ uint numlockmask; -Alias *confalias; #endif /* WMFS_H */