about summary refs log tree commit diff
path: root/main.c
diff options
context:
space:
mode:
authorAnselm R.Garbe <arg@10ksloc.org>2006-08-16 19:25:04 +0200
committerAnselm R.Garbe <arg@10ksloc.org>2006-08-16 19:25:04 +0200
commitbbb2cc2a729cac8d0b2f0233924ad0491f00c2d7 (patch)
treeb004c275a08dd3c4d7aed6223a9802511d380ff3 /main.c
parentapplied sanders patch (diff)
downloaddmenu-bbb2cc2a729cac8d0b2f0233924ad0491f00c2d7.tar.gz
dmenu-bbb2cc2a729cac8d0b2f0233924ad0491f00c2d7.tar.bz2
dmenu-bbb2cc2a729cac8d0b2f0233924ad0491f00c2d7.zip
fixed a typo in config.mk, fixed cleanup code in dmenu (now frees all allocated stuff)
Diffstat (limited to 'main.c')
-rw-r--r--main.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/main.c b/main.c
index 3b9a24b..2f20efb 100644
--- a/main.c
+++ b/main.c
@@ -29,7 +29,7 @@ static int mx, my, mw, mh;
 static int ret = 0;
 static int nitem = 0;
 static unsigned int cmdw = 0;
-static Bool done = False;
+static Bool running = True;
 static Item *allitems = NULL;	/* first of all items */
 static Item *item = NULL;	/* first of pattern matching items */
 static Item *sel = NULL;
@@ -219,11 +219,11 @@ kpress(XKeyEvent * e)
 		else if(text)
 			fprintf(stdout, "%s", text);
 		fflush(stdout);
-		done = True;
+		running = False;
 		break;
 	case XK_Escape:
 		ret = 1;
-		done = True;
+		running = False;
 		break;
 	case XK_BackSpace:
 		if((i = len)) {
@@ -290,6 +290,7 @@ int
 main(int argc, char *argv[])
 {
 	char *maxname;
+	Item *i;
 	XEvent ev;
 	XSetWindowAttributes wa;
 
@@ -349,7 +350,7 @@ main(int argc, char *argv[])
 	XSync(dpy, False);
 
 	/* main event loop */
-	while(!done && !XNextEvent(dpy, &ev)) {
+	while(running && !XNextEvent(dpy, &ev)) {
 		switch (ev.type) {
 		case KeyPress:
 			kpress(&ev.xkey);
@@ -364,6 +365,16 @@ main(int argc, char *argv[])
 	}
 
 	XUngrabKeyboard(dpy, CurrentTime);
+	while(allitems) {
+		i = allitems->next;
+		free(allitems->text);
+		free(allitems);
+		allitems = i;
+	}
+	if(dc.font.set)
+		XFreeFontSet(dpy, dc.font.set);
+	else
+		XFreeFont(dpy, dc.font.xfont);
 	XFreePixmap(dpy, dc.drawable);
 	XFreeGC(dpy, dc.gc);
 	XDestroyWindow(dpy, win);