aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokan2009-06-20 00:22:39 +0000
committerokan2009-06-20 00:22:39 +0000
commitc6af5e9b967797d315037b26aa05fec5b3e6ef44 (patch)
treed43509362b21d72dea32d8a79f4b199e95b0f566
parent5065e7cff4666b454fb3c16be050811f58b9f24f (diff)
downloadcwm-c6af5e9b967797d315037b26aa05fec5b3e6ef44.tar.gz
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@
Diffstat (limited to '')
-rw-r--r--calmwm.c4
-rw-r--r--calmwm.h5
-rw-r--r--client.c6
-rw-r--r--conf.c9
-rw-r--r--group.c4
-rw-r--r--kbfunc.c10
-rw-r--r--menu.c2
-rw-r--r--mousefunc.c6
-rw-r--r--parse.y8
9 files changed, 25 insertions, 29 deletions
diff --git a/calmwm.c b/calmwm.c
index 67e76a3..eb924e8 100644
--- a/calmwm.c
+++ b/calmwm.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.
*
- * $Id: calmwm.c,v 1.39 2009/05/18 00:23:35 okan Exp $
+ * $Id: calmwm.c,v 1.40 2009/06/20 00:22:39 okan Exp $
*/
#include "headers.h"
@@ -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 f0717fc..e972452 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.
*
- * $Id: calmwm.h,v 1.91 2009/06/17 12:30:17 okan Exp $
+ * $Id: calmwm.h,v 1.92 2009/06/20 00:22:39 okan Exp $
*/
#ifndef _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 47218f3..7c6b470 100644
--- a/client.c
+++ b/client.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.
*
- * $Id: client.c,v 1.53 2009/06/20 00:19:56 okan Exp $
+ * $Id: client.c,v 1.54 2009/06/20 00:22:39 okan Exp $
*/
#include "headers.h"
@@ -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 ef26183..fdf9e60 100644
--- a/conf.c
+++ b/conf.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.
*
- * $Id: conf.c,v 1.64 2009/06/20 00:19:56 okan Exp $
+ * $Id: conf.c,v 1.65 2009/06/20 00:22:39 okan Exp $
*/
#include "headers.h"
@@ -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 5282200..b11de89 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.
*
- * $Id: group.c,v 1.30 2009/05/19 12:49:37 sthen Exp $
+ * $Id: group.c,v 1.31 2009/06/20 00:22:39 okan Exp $
*/
#include "headers.h"
@@ -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 3231190..a205c83 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.
*
- * $Id: kbfunc.c,v 1.38 2009/05/17 17:04:59 sthen Exp $
+ * $Id: kbfunc.c,v 1.39 2009/06/20 00:22:39 okan Exp $
*/
#include <paths.h>
@@ -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 7653769..ff6ddeb 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.
*
- * $Id: mousefunc.c,v 1.10 2009/06/17 12:45:01 okan Exp $
+ * $Id: mousefunc.c,v 1.11 2009/06/20 00:22:39 okan Exp $
*/
#include "headers.h"
@@ -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 72489fa..9c501bc 100644
--- a/parse.y
+++ b/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.20 2009/05/17 23:40:57 okan Exp $ */
+/* $OpenBSD: parse.y,v 1.21 2009/06/20 00:22:39 okan Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -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);