aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authoroga2008-04-16 13:38:09 +0000
committeroga2008-04-16 13:38:09 +0000
commit579efe92d1c484a6d8b9399b2abdb6440f9e92ea (patch)
tree54a68e890f6637336f92a6cd965818e3b14cafe8 /parse.y
parent02211e5b89f2fd8670b150d7892f56d0f6dba351 (diff)
downloadcwm-579efe92d1c484a6d8b9399b2abdb6440f9e92ea.tar.gz
Replace a few leftover calls to strdup and calloc with xstrdup and xcalloc
respectively. ok okan.
Diffstat (limited to '')
-rw-r--r--parse.y17
1 files changed, 6 insertions, 11 deletions
diff --git a/parse.y b/parse.y
index a218642..a6fe7fa 100644
--- a/parse.y
+++ b/parse.y
@@ -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>
@@ -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);