Replace a few leftover calls to strdup and calloc with xstrdup and xcalloc
respectively. ok okan.
This commit is contained in:
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);
|
||||
|
||||
Reference in New Issue
Block a user