Replace a few leftover calls to strdup and calloc with xstrdup and xcalloc
respectively. ok okan.
This commit is contained in:
parent
9aedc9e805
commit
f062e958e0
@ -15,7 +15,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $Id: calmwm.h,v 1.34 2008/04/16 13:35:37 oga Exp $
|
* $Id: calmwm.h,v 1.35 2008/04/16 13:38:09 oga Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CALMWM_H_
|
#ifndef _CALMWM_H_
|
||||||
@ -409,11 +409,11 @@ void grab_label(struct client_ctx *);
|
|||||||
|
|
||||||
void xfree(void *);
|
void xfree(void *);
|
||||||
void *xmalloc(size_t);
|
void *xmalloc(size_t);
|
||||||
void *xcalloc(size_t);
|
void *xcalloc(size_t, size_t);
|
||||||
char *xstrdup(const char *);
|
char *xstrdup(const char *);
|
||||||
|
|
||||||
#define XMALLOC(p, t) ((p) = (t *)xmalloc(sizeof * (p)))
|
#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);
|
void screen_init(void);
|
||||||
struct screen_ctx *screen_fromroot(Window);
|
struct screen_ctx *screen_fromroot(Window);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $Id: conf.c,v 1.26 2008/04/15 20:24:41 oga Exp $
|
* $Id: conf.c,v 1.27 2008/04/16 13:38:09 oga Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
@ -360,7 +360,7 @@ conf_bindname(struct conf *c, char *name, char *binding)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
current_binding->callback = kbfunc_cmdexec;
|
current_binding->callback = kbfunc_cmdexec;
|
||||||
current_binding->argument = strdup(binding);
|
current_binding->argument = xstrdup(binding);
|
||||||
current_binding->flags = 0;
|
current_binding->flags = 0;
|
||||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||||
return;
|
return;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $Id: group.c,v 1.10 2008/04/16 13:35:37 oga Exp $
|
* $Id: group.c,v 1.11 2008/04/16 13:38:09 oga Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
@ -85,7 +85,7 @@ _group_show(struct group_ctx *gc)
|
|||||||
u_int i;
|
u_int i;
|
||||||
int lastempty = -1;
|
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
|
* Invert the stacking order as XRestackWindows() expects them
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: parse.y,v 1.4 2008/04/15 20:24:41 oga Exp $ */
|
/* $OpenBSD: parse.y,v 1.5 2008/04/16 13:38:09 oga Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
|
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
|
||||||
@ -359,9 +359,7 @@ yylex(void)
|
|||||||
}
|
}
|
||||||
*p++ = (char)c;
|
*p++ = (char)c;
|
||||||
}
|
}
|
||||||
yylval.v.string = strdup(buf);
|
yylval.v.string = xstrdup(buf);
|
||||||
if (yylval.v.string == NULL)
|
|
||||||
err(1, "yylex: strdup");
|
|
||||||
return (STRING);
|
return (STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,8 +416,7 @@ nodigits:
|
|||||||
lungetc(c);
|
lungetc(c);
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
if ((token = lookup(buf)) == STRING)
|
if ((token = lookup(buf)) == STRING)
|
||||||
if ((yylval.v.string = strdup(buf)) == NULL)
|
yylval.v.string = xstrdup(buf);
|
||||||
err(1, "yylex: strdup");
|
|
||||||
return (token);
|
return (token);
|
||||||
}
|
}
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
@ -436,11 +433,9 @@ pushfile(const char *name)
|
|||||||
{
|
{
|
||||||
struct file *nfile;
|
struct file *nfile;
|
||||||
|
|
||||||
if ((nfile = calloc(1, sizeof(struct file))) == NULL ||
|
nfile = xcalloc(1, sizeof(struct file));
|
||||||
(nfile->name = strdup(name)) == NULL) {
|
nfile->name = xstrdup(name);
|
||||||
warn("malloc");
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
|
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
|
||||||
warn("%s", nfile->name);
|
warn("%s", nfile->name);
|
||||||
free(nfile->name);
|
free(nfile->name);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $Id: xmalloc.c,v 1.2 2008/01/11 16:06:44 oga Exp $
|
* $Id: xmalloc.c,v 1.3 2008/04/16 13:38:09 oga Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
@ -33,11 +33,11 @@ xmalloc(size_t siz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
xcalloc(size_t siz)
|
xcalloc(size_t no, size_t siz)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
if ((p = calloc(1, siz)) == NULL)
|
if ((p = calloc(no, siz)) == NULL)
|
||||||
err(1, "calloc");
|
err(1, "calloc");
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
|
Loading…
Reference in New Issue
Block a user