diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-09-26 16:47:12 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-09-26 16:47:12 +0000 |
| commit | adb9bb700f3235728dacc1d3e3daad81abd93e9a (patch) | |
| tree | 59f659d62fbd6ae6e642276823d6484e17afa13f /openbox/action.c | |
| parent | 9ed3baf9dbf0c4c1dcf4b63262eca03247b50a0d (diff) | |
give actions a ref count
Diffstat (limited to 'openbox/action.c')
| -rw-r--r-- | openbox/action.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/openbox/action.c b/openbox/action.c index bef87680..52a602cc 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -65,19 +65,26 @@ typedef struct void (*setup)(ObAction **, ObUserAction uact); } ActionString; -static ObAction *action_new(void (*func)(union ActionData *data), - ObUserAction uact) +static ObAction *action_new(void (*func)(union ActionData *data)) { ObAction *a = g_new0(ObAction, 1); + a->ref = 1; a->func = func; return a; } -void action_free(ObAction *a) +void action_ref(ObAction *a) +{ + ++a->ref; +} + +void action_unref(ObAction *a) { if (a == NULL) return; + if (--a->ref > 0) return; + /* deal with pointers */ if (a->func == action_execute || a->func == action_restart) g_free(a->data.execute.path); @@ -359,7 +366,7 @@ void setup_action_showmenu(ObAction **a, ObUserAction uact) assumptions that there is only one menu (and submenus) open at a time! */ if (uact == OB_USER_ACTION_MENU_SELECTION) { - action_free(*a); + action_unref(*a); a = NULL; } } @@ -772,7 +779,7 @@ ObAction *action_from_string(const gchar *name, ObUserAction uact) for (i = 0; actionstrings[i].name; i++) if (!g_ascii_strcasecmp(name, actionstrings[i].name)) { exist = TRUE; - a = action_new(actionstrings[i].func, uact); + a = action_new(actionstrings[i].func); if (actionstrings[i].setup) actionstrings[i].setup(&a, uact); /* only key bindings can be interactive. thus saith the xor. |
