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@
This commit is contained in:
okan 2009-06-20 00:22:39 +00:00
parent 0230e26854
commit a7dfb91b88
9 changed files with 25 additions and 29 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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++;

View File

@ -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, '-'))

View File

@ -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]);

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);