aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calmwm.h3
-rw-r--r--group.c7
-rw-r--r--kbfunc.c22
-rw-r--r--menu.c18
-rw-r--r--mousefunc.c15
5 files changed, 26 insertions, 39 deletions
diff --git a/calmwm.h b/calmwm.h
index 86e1bc6..f8786d7 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.h,v 1.166 2012/12/17 14:20:52 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.167 2012/12/17 14:32:39 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -431,6 +431,7 @@ struct menu *menu_filter(struct screen_ctx *, struct menu_q *,
void (*)(struct menu_q *, struct menu_q *, char *),
void (*)(struct menu *, int));
void menu_init(struct screen_ctx *);
+void menuq_clear(struct menu_q *);
int parse_config(const char *, struct conf *);
diff --git a/group.c b/group.c
index 386fdc9..4c268c7 100644
--- a/group.c
+++ b/group.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: group.c,v 1.64 2012/11/29 04:25:49 okan Exp $
+ * $OpenBSD: group.c,v 1.65 2012/12/17 14:32:39 okan Exp $
*/
#include <sys/param.h>
@@ -385,10 +385,7 @@ group_menu(XButtonEvent *e)
(gc->hidden) ? group_show(sc, gc) : group_hide(sc, gc);
cleanup:
- while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
- TAILQ_REMOVE(&menuq, mi, entry);
- free(mi);
- }
+ menuq_clear(&menuq);
}
void
diff --git a/kbfunc.c b/kbfunc.c
index 3bf2c9d..f58982b 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: kbfunc.c,v 1.68 2012/11/09 03:52:02 okan Exp $
+ * $OpenBSD: kbfunc.c,v 1.69 2012/12/17 14:32:39 okan Exp $
*/
#include <sys/param.h>
@@ -168,10 +168,7 @@ kbfunc_client_search(struct client_ctx *cc, union arg *arg)
client_ptrwarp(cc);
}
- while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
- TAILQ_REMOVE(&menuq, mi, entry);
- free(mi);
- }
+ menuq_clear(&menuq);
}
void
@@ -195,10 +192,7 @@ kbfunc_menu_search(struct client_ctx *cc, union arg *arg)
search_match_text, NULL)) != NULL)
u_spawn(((struct cmd *)mi->ctx)->image);
- while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
- TAILQ_REMOVE(&menuq, mi, entry);
- free(mi);
- }
+ menuq_clear(&menuq);
}
void
@@ -320,10 +314,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
out:
if (mi != NULL && mi->dummy)
free(mi);
- while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
- TAILQ_REMOVE(&menuq, mi, entry);
- free(mi);
- }
+ menuq_clear(&menuq);
}
void
@@ -390,10 +381,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
out:
if (mi != NULL && mi->dummy)
free(mi);
- while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
- TAILQ_REMOVE(&menuq, mi, entry);
- free(mi);
- }
+ menuq_clear(&menuq);
}
void
diff --git a/menu.c b/menu.c
index 0023637..261e481 100644
--- a/menu.c
+++ b/menu.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: menu.c,v 1.47 2012/12/17 02:53:29 okan Exp $
+ * $OpenBSD: menu.c,v 1.48 2012/12/17 14:32:39 okan Exp $
*/
#include <sys/param.h>
@@ -215,10 +215,7 @@ menu_complete_path(struct menu_ctx *mc)
strlcpy(path, mi->text, sizeof(mi->text));
}
- while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
- TAILQ_REMOVE(&menuq, mi, entry);
- free(mi);
- }
+ menuq_clear(&menuq);
if (path[0] != '\0')
snprintf(mr->text, sizeof(mr->text), "%s \"%s\"",
@@ -632,3 +629,14 @@ menu_keycode(XKeyEvent *ev, enum ctltype *ctl, char *chr)
return (0);
}
+
+void
+menuq_clear(struct menu_q *mq)
+{
+ struct menu *mi;
+
+ while ((mi = TAILQ_FIRST(mq)) != NULL) {
+ TAILQ_REMOVE(mq, mi, entry);
+ free(mi);
+ }
+}
diff --git a/mousefunc.c b/mousefunc.c
index 01881e1..f5ea3f0 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: mousefunc.c,v 1.41 2012/12/17 02:28:45 okan Exp $
+ * $OpenBSD: mousefunc.c,v 1.42 2012/12/17 14:32:39 okan Exp $
*/
#include <sys/param.h>
@@ -250,12 +250,8 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
if (old_cc != NULL)
client_ptrsave(old_cc);
client_ptrwarp(cc);
- } else {
- while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
- TAILQ_REMOVE(&menuq, mi, entry);
- free(mi);
- }
- }
+ } else
+ menuq_clear(&menuq);
}
void
@@ -280,8 +276,5 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
if (mi != NULL)
u_spawn(((struct cmd *)mi->ctx)->image);
else
- while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
- TAILQ_REMOVE(&menuq, mi, entry);
- free(mi);
- }
+ menuq_clear(&menuq);
}