mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Replace a few leftover calls to strdup and calloc with xstrdup and xcalloc
respectively. ok okan.
This commit is contained in:
parent
f67772be65
commit
f473dc3d12
4
calmwm.h
4
calmwm.h
@ -409,11 +409,11 @@ void grab_label(struct client_ctx *);
|
||||
|
||||
void xfree(void *);
|
||||
void *xmalloc(size_t);
|
||||
void *xcalloc(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(sizeof * (p)))
|
||||
#define XCALLOC(p, t) ((p) = (t *)xcalloc(1, sizeof * (p)))
|
||||
|
||||
void screen_init(void);
|
||||
struct screen_ctx *screen_fromroot(Window);
|
||||
|
2
conf.c
2
conf.c
@ -360,7 +360,7 @@ conf_bindname(struct conf *c, char *name, char *binding)
|
||||
return;
|
||||
|
||||
current_binding->callback = kbfunc_cmdexec;
|
||||
current_binding->argument = strdup(binding);
|
||||
current_binding->argument = xstrdup(binding);
|
||||
current_binding->flags = 0;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||
return;
|
||||
|
2
group.c
2
group.c
@ -85,7 +85,7 @@ _group_show(struct group_ctx *gc)
|
||||
u_int i;
|
||||
int lastempty = -1;
|
||||
|
||||
winlist = (Window *) xcalloc(sizeof(*winlist) * (gc->highstack + 1));
|
||||
winlist = (Window *) xcalloc(sizeof(*winlist), (gc->highstack + 1));
|
||||
|
||||
/*
|
||||
* Invert the stacking order as XRestackWindows() expects them
|
||||
|
15
parse.y
15
parse.y
@ -359,9 +359,7 @@ yylex(void)
|
||||
}
|
||||
*p++ = (char)c;
|
||||
}
|
||||
yylval.v.string = strdup(buf);
|
||||
if (yylval.v.string == NULL)
|
||||
err(1, "yylex: strdup");
|
||||
yylval.v.string = xstrdup(buf);
|
||||
return (STRING);
|
||||
}
|
||||
|
||||
@ -418,8 +416,7 @@ nodigits:
|
||||
lungetc(c);
|
||||
*p = '\0';
|
||||
if ((token = lookup(buf)) == STRING)
|
||||
if ((yylval.v.string = strdup(buf)) == NULL)
|
||||
err(1, "yylex: strdup");
|
||||
yylval.v.string = xstrdup(buf);
|
||||
return (token);
|
||||
}
|
||||
if (c == '\n') {
|
||||
@ -436,11 +433,9 @@ pushfile(const char *name)
|
||||
{
|
||||
struct file *nfile;
|
||||
|
||||
if ((nfile = calloc(1, sizeof(struct file))) == NULL ||
|
||||
(nfile->name = strdup(name)) == NULL) {
|
||||
warn("malloc");
|
||||
return (NULL);
|
||||
}
|
||||
nfile = xcalloc(1, sizeof(struct file));
|
||||
nfile->name = xstrdup(name);
|
||||
|
||||
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
|
||||
warn("%s", nfile->name);
|
||||
free(nfile->name);
|
||||
|
Loading…
Reference in New Issue
Block a user