diff options
author | oga <oga> | 2008-04-16 13:38:09 +0000 |
---|---|---|
committer | oga <oga> | 2008-04-16 13:38:09 +0000 |
commit | f473dc3d12f4a1237fa020bff58fd44c3c6489de (patch) | |
tree | 7584efc245cd1a99b292a7fe07f3dbcf60eab7fc /parse.y | |
parent | f67772be650718b2e408a26ef08e1946a0abf1ab (diff) | |
download | cwm-f473dc3d12f4a1237fa020bff58fd44c3c6489de.tar.gz cwm-f473dc3d12f4a1237fa020bff58fd44c3c6489de.tar.xz cwm-f473dc3d12f4a1237fa020bff58fd44c3c6489de.zip |
Replace a few leftover calls to strdup and calloc with xstrdup and xcalloc
respectively. ok okan.
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/parse.y b/parse.y index b3bfbf8..536d3b8 100644 --- a/parse.y +++ b/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); |