summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2009-06-20 00:22:39 +0000
committerokan <okan>2009-06-20 00:22:39 +0000
commit58d12134b1679a9172a7131abffc27769780b9c5 (patch)
treeffd2aa13b869b39db64f2a18488c87bfc2aa9882
parent18c7d89c985cda7a9a5fa7de7c13ae177509380b (diff)
downloadcwm-58d12134b1679a9172a7131abffc27769780b9c5.tar.gz
cwm-58d12134b1679a9172a7131abffc27769780b9c5.tar.xz
cwm-58d12134b1679a9172a7131abffc27769780b9c5.zip
unroll XCALLOC/XMALLOC macros; since we use xcalloc/xmalloc all over the
place anyway, this makes things a bit more consistent; from Thomas Pfaff

ok oga@
-rw-r--r--calmwm.c2
-rw-r--r--calmwm.h3
-rw-r--r--client.c4
-rw-r--r--conf.c7
-rw-r--r--group.c2
-rw-r--r--kbfunc.c8
-rw-r--r--menu.c2
-rw-r--r--mousefunc.c4
-rw-r--r--parse.y6
9 files changed, 17 insertions, 21 deletions
diff --git a/calmwm.c b/calmwm.c
index cfe0091..f9647af 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -111,7 +111,7 @@ x_setup(void)
 	int			 i;
 
 	for (i = 0; i < ScreenCount(X_Dpy); i++) {
-		XCALLOC(sc, struct screen_ctx);
+		sc = xcalloc(1, sizeof(*sc));
 		x_setupscreen(sc, i);
 		TAILQ_INSERT_TAIL(&Screenq, sc, entry);
 	}
diff --git a/calmwm.h b/calmwm.h
index c796058..58ed382 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -395,9 +395,6 @@ void			*xmalloc(size_t);
 void			*xcalloc(size_t, size_t);
 char			*xstrdup(const char *);
 
-#define XMALLOC(p, t) ((p) = (t *)xmalloc(sizeof * (p)))
-#define XCALLOC(p, t) ((p) = (t *)xcalloc(1, sizeof * (p)))
-
 struct screen_ctx	*screen_fromroot(Window);
 struct screen_ctx	*screen_current(void);
 void			 screen_updatestackingorder(void);
diff --git a/client.c b/client.c
index 3b0bc33..05dff6e 100644
--- a/client.c
+++ b/client.c
@@ -56,7 +56,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
 	if (win == None)
 		return (NULL);
 
-	XCALLOC(cc, struct client_ctx);
+	cc = xcalloc(1, sizeof(*cc));
 
 	XGrabServer(X_Dpy);
 
@@ -462,7 +462,7 @@ client_setname(struct client_ctx *cc)
 			goto match;
 		}
 
-	XMALLOC(wn, struct winname);
+	wn = xmalloc(sizeof(*wn));
 	wn->name = newname;
 	TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
 	cc->nameqlen++;
diff --git a/conf.c b/conf.c
index a09d061..3161f8a 100644
--- a/conf.c
+++ b/conf.c
@@ -41,8 +41,7 @@ conf_cmd_add(struct conf *c, char *image, char *label, int flags)
 	else if (strcmp(label, "lock") == 0)
 		strlcpy(c->lockpath, image, sizeof(c->lockpath));
 	else {
-		struct cmd *cmd;
-		XMALLOC(cmd, struct cmd);
+		struct cmd *cmd = xmalloc(sizeof(*cmd));
 		cmd->flags = flags;
 		strlcpy(cmd->image, image, sizeof(cmd->image));
 		strlcpy(cmd->label, label, sizeof(cmd->label));
@@ -429,7 +428,7 @@ conf_bindname(struct conf *c, char *name, char *binding)
 	char			*substring;
 	int			 iter;
 
-	XCALLOC(current_binding, struct keybinding);
+	current_binding = xcalloc(1, sizeof(*current_binding));
 
 	if (strchr(name, 'C') != NULL &&
 	    strchr(name, 'C') < strchr(name, '-'))
@@ -541,7 +540,7 @@ conf_mousebind(struct conf *c, char *name, char *binding)
 	const char		*errstr;
 	int			 iter;
 
-	XCALLOC(current_binding, struct mousebinding);
+	current_binding = xcalloc(1, sizeof(*current_binding));
 
 	if (strchr(name, 'C') != NULL &&
 	    strchr(name, 'C') < strchr(name, '-'))
diff --git a/group.c b/group.c
index 034ae6a..96f2290 100644
--- a/group.c
+++ b/group.c
@@ -304,7 +304,7 @@ group_menu(XButtonEvent *e)
 		if (TAILQ_EMPTY(&gc->clients))
 			continue;
 
-		XCALLOC(mi, struct menu);
+		mi = xcalloc(1, sizeof(*mi));
 		if (gc->hidden)
 			snprintf(mi->text, sizeof(mi->text), "%d: [%s]",
 			    gc->shortcut, shortcut_to_name[gc->shortcut]);
diff --git a/kbfunc.c b/kbfunc.c
index d7814ab..1f3b843 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -135,7 +135,7 @@ kbfunc_client_search(struct client_ctx *scratch, union arg *arg)
 	TAILQ_INIT(&menuq);
 
 	TAILQ_FOREACH(cc, &Clientq, entry) {
-		XCALLOC(mi, struct menu);
+		mi = xcalloc(1, sizeof(*mi));
 		strlcpy(mi->text, cc->name, sizeof(mi->text));
 		mi->ctx = cc;
 		TAILQ_INSERT_TAIL(&menuq, mi, entry);
@@ -168,7 +168,7 @@ kbfunc_menu_search(struct client_ctx *scratch, union arg *arg)
 	TAILQ_INIT(&menuq);
 
 	TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
-		XCALLOC(mi, struct menu);
+		mi = xcalloc(1, sizeof(*mi));
 		strlcpy(mi->text, cmd->label, sizeof(mi->text));
 		mi->ctx = cmd;
 		TAILQ_INSERT_TAIL(&menuq, mi, entry);
@@ -304,7 +304,7 @@ kbfunc_exec(struct client_ctx *scratch, union arg *arg)
 			continue;
 		executable:
 			/* the thing in tpath, we may execute */
-			XCALLOC(mi, struct menu);
+			mi = xcalloc(1, sizeof(*mi));
 			strlcpy(mi->text, dp->d_name, sizeof(mi->text));
 			TAILQ_INSERT_TAIL(&menuq, mi, entry);
 		}
@@ -380,7 +380,7 @@ kbfunc_ssh(struct client_ctx *scratch, union arg *arg)
 		if (p - buf + 1 > sizeof(hostbuf))
 			continue;
 		(void) strlcpy(hostbuf, buf, p - buf + 1);
-		XCALLOC(mi, struct menu);
+		mi = xcalloc(1, sizeof(*mi));
 		(void) strlcpy(mi->text, hostbuf, sizeof(mi->text));
 		TAILQ_INSERT_TAIL(&menuq, mi, entry);
 	}
diff --git a/menu.c b/menu.c
index 16cf400..ea4a24f 100644
--- a/menu.c
+++ b/menu.c
@@ -383,7 +383,7 @@ menu_handle_release(XEvent *e, struct menu_ctx *mc, struct screen_ctx *sc,
 		if (entry == i++)
 			break;
 	if (mi == NULL) {
-		XMALLOC(mi, struct menu);
+		mi = xmalloc(sizeof(*mi));
 		mi->text[0] = '\0';
 		mi->dummy = 1;
 	}
diff --git a/mousefunc.c b/mousefunc.c
index b98a073..00ccab5 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -234,7 +234,7 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
 			if (wname == NULL)
 				continue;
 
-			XCALLOC(mi, struct menu);
+			mi = xcalloc(1, sizeof(*mi));
 			strlcpy(mi->text, wname, sizeof(mi->text));
 			mi->ctx = cc;
 			TAILQ_INSERT_TAIL(&menuq, mi, entry);
@@ -268,7 +268,7 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
 
 	TAILQ_INIT(&menuq);
 	TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
-		XCALLOC(mi, struct menu);
+		mi = xcalloc(1, sizeof(*mi));
 		strlcpy(mi->text, cmd->label, sizeof(mi->text));
 		mi->ctx = cmd;
 		TAILQ_INSERT_TAIL(&menuq, mi, entry);
diff --git a/parse.y b/parse.y
index 272b587..435c2a2 100644
--- a/parse.y
+++ b/parse.y
@@ -132,7 +132,7 @@ main		: FONTNAME STRING		{
 				YYERROR;
 			}
 
-			XCALLOC(aw, struct autogroupwin);
+			aw = xcalloc(1, sizeof(*aw));
 
 			if ((p = strchr($3, ',')) == NULL) {
 				aw->name = NULL;
@@ -151,7 +151,7 @@ main		: FONTNAME STRING		{
 		| IGNORE STRING {
 			struct winmatch	*wm;
 
-			XCALLOC(wm, struct winmatch);
+			wm = xcalloc(1, sizeof(*wm));
 			strlcpy(wm->title, $2, sizeof(wm->title));
 			TAILQ_INSERT_TAIL(&conf->ignoreq, wm, entry);
 
@@ -503,7 +503,7 @@ parse_config(const char *filename, struct conf *xconf)
 {
 	int			 errors = 0;
 
-	XCALLOC(conf, struct conf);
+	conf = xcalloc(1, sizeof(*conf));
 
 	if ((file = pushfile(filename)) == NULL) {
 		free(conf);