summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/cwm/calmwm.h3
-rw-r--r--app/cwm/group.c7
-rw-r--r--app/cwm/kbfunc.c22
-rw-r--r--app/cwm/menu.c18
-rw-r--r--app/cwm/mousefunc.c15
5 files changed, 26 insertions, 39 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index 86e1bc6e3..f8786d7d5 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/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/app/cwm/group.c b/app/cwm/group.c
index 386fdc9e4..4c268c7ca 100644
--- a/app/cwm/group.c
+++ b/app/cwm/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/app/cwm/kbfunc.c b/app/cwm/kbfunc.c
index 3bf2c9d90..f58982b5a 100644
--- a/app/cwm/kbfunc.c
+++ b/app/cwm/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/app/cwm/menu.c b/app/cwm/menu.c
index 00236374c..261e4814f 100644
--- a/app/cwm/menu.c
+++ b/app/cwm/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/app/cwm/mousefunc.c b/app/cwm/mousefunc.c
index 01881e14d..f5ea3f05f 100644
--- a/app/cwm/mousefunc.c
+++ b/app/cwm/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);
}