mirror of
https://github.com/labwc/labwc.git
synced 2026-04-10 08:21:07 -04:00
Centralize freeing of action lists
Reduces some code duplication and makes it easier to extend struct action
This commit is contained in:
parent
8e9643a855
commit
26e025efa1
4 changed files with 14 additions and 17 deletions
|
|
@ -12,6 +12,7 @@ struct action {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct action *action_create(const char *action_name);
|
struct action *action_create(const char *action_name);
|
||||||
|
void action_list_free(struct wl_list *action_list);
|
||||||
|
|
||||||
void action(struct view *activator, struct server *server,
|
void action(struct view *activator, struct server *server,
|
||||||
struct wl_list *actions, uint32_t resize_edges);
|
struct wl_list *actions, uint32_t resize_edges);
|
||||||
|
|
|
||||||
10
src/action.c
10
src/action.c
|
|
@ -2,6 +2,7 @@
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "common/spawn.h"
|
#include "common/spawn.h"
|
||||||
|
#include "common/zfree.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "menu/menu.h"
|
#include "menu/menu.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
|
|
@ -76,6 +77,15 @@ action_create(const char *action_name)
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void action_list_free(struct wl_list *action_list) {
|
||||||
|
struct action *action, *action_tmp;
|
||||||
|
wl_list_for_each_safe(action, action_tmp, action_list, link) {
|
||||||
|
wl_list_remove(&action->link);
|
||||||
|
zfree(action->arg);
|
||||||
|
zfree(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_menu(struct server *server, const char *menu)
|
show_menu(struct server *server, const char *menu)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -676,7 +676,6 @@ no_config:
|
||||||
void
|
void
|
||||||
rcxml_finish(void)
|
rcxml_finish(void)
|
||||||
{
|
{
|
||||||
struct action *action, *action_tmp;
|
|
||||||
|
|
||||||
zfree(rc.font_name_activewindow);
|
zfree(rc.font_name_activewindow);
|
||||||
zfree(rc.font_name_menuitem);
|
zfree(rc.font_name_menuitem);
|
||||||
|
|
@ -686,11 +685,7 @@ rcxml_finish(void)
|
||||||
struct keybind *k, *k_tmp;
|
struct keybind *k, *k_tmp;
|
||||||
wl_list_for_each_safe(k, k_tmp, &rc.keybinds, link) {
|
wl_list_for_each_safe(k, k_tmp, &rc.keybinds, link) {
|
||||||
wl_list_remove(&k->link);
|
wl_list_remove(&k->link);
|
||||||
wl_list_for_each_safe(action, action_tmp, &k->actions, link) {
|
action_list_free(&k->actions);
|
||||||
wl_list_remove(&action->link);
|
|
||||||
zfree(action->arg);
|
|
||||||
zfree(action);
|
|
||||||
}
|
|
||||||
zfree(k->keysyms);
|
zfree(k->keysyms);
|
||||||
zfree(k);
|
zfree(k);
|
||||||
}
|
}
|
||||||
|
|
@ -698,11 +693,7 @@ rcxml_finish(void)
|
||||||
struct mousebind *m, *m_tmp;
|
struct mousebind *m, *m_tmp;
|
||||||
wl_list_for_each_safe(m, m_tmp, &rc.mousebinds, link) {
|
wl_list_for_each_safe(m, m_tmp, &rc.mousebinds, link) {
|
||||||
wl_list_remove(&m->link);
|
wl_list_remove(&m->link);
|
||||||
wl_list_for_each_safe(action, action_tmp, &m->actions, link) {
|
action_list_free(&m->actions);
|
||||||
wl_list_remove(&action->link);
|
|
||||||
zfree(action->arg);
|
|
||||||
zfree(action);
|
|
||||||
}
|
|
||||||
zfree(m);
|
zfree(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -330,17 +330,12 @@ void
|
||||||
menu_finish(void)
|
menu_finish(void)
|
||||||
{
|
{
|
||||||
struct menu *menu;
|
struct menu *menu;
|
||||||
struct action *action, *action_tmp;
|
|
||||||
for (int i = 0; i < nr_menus; ++i) {
|
for (int i = 0; i < nr_menus; ++i) {
|
||||||
menu = menus + i;
|
menu = menus + i;
|
||||||
struct menuitem *item, *next;
|
struct menuitem *item, *next;
|
||||||
wl_list_for_each_safe(item, next, &menu->menuitems, link) {
|
wl_list_for_each_safe(item, next, &menu->menuitems, link) {
|
||||||
wl_list_remove(&item->link);
|
wl_list_remove(&item->link);
|
||||||
wl_list_for_each_safe(action, action_tmp, &item->actions, link) {
|
action_list_free(&item->actions);
|
||||||
wl_list_remove(&action->link);
|
|
||||||
zfree(action->arg);
|
|
||||||
zfree(action);
|
|
||||||
}
|
|
||||||
free(item);
|
free(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue