diff options
author | mmcc <mmcc@cvs.openbsd.org> | 2015-12-28 19:14:05 +0000 |
---|---|---|
committer | mmcc <mmcc@cvs.openbsd.org> | 2015-12-28 19:14:05 +0000 |
commit | be7e3d7f5f893bdaf825b58421d51b8673ede014 (patch) | |
tree | 9ba835048280ff96909eeac130699ecce2d4c2ab /usr.bin | |
parent | 18326868773a46088a443019ea63bd68a3a11231 (diff) |
realloc and free's behavior when passed NULL is defined by C89, so we
can safely assume it.
ok millert@. Also discussed with deraadt@, sthen@, and espie@.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/yacc/skeleton.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/usr.bin/yacc/skeleton.c b/usr.bin/yacc/skeleton.c index 28832605a41..e04f8e18d8f 100644 --- a/usr.bin/yacc/skeleton.c +++ b/usr.bin/yacc/skeleton.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skeleton.c,v 1.35 2014/03/16 18:38:30 guenther Exp $ */ +/* $OpenBSD: skeleton.c,v 1.36 2015/12/28 19:14:04 mmcc Exp $ */ /* $NetBSD: skeleton.c,v 1.10 1996/03/25 00:36:18 mrg Exp $ */ /* @@ -137,16 +137,14 @@ char *body[] = "#endif", " if (newsize && YY_SIZE_MAX / newsize < sizeof *newss)", " goto bail;", - " newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :", - " (short *)malloc(newsize * sizeof *newss); /* overflow check above */", + " newss = realloc(yyss, newsize * sizeof(*newss)); /* overflow check above */", " if (newss == NULL)", " goto bail;", " yyss = newss;", " yyssp = newss + sslen;", " if (newsize && YY_SIZE_MAX / newsize < sizeof *newvs)", " goto bail;", - " newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :", - " (YYSTYPE *)malloc(newsize * sizeof *newvs); /* overflow check above */", + " newvs = realloc(yyvs, newsize * sizeof(*newvs)); /* overflow check above */", " if (newvs == NULL)", " goto bail;", " yyvs = newvs;", @@ -155,10 +153,8 @@ char *body[] = " yysslim = yyss + newsize - 1;", " return 0;", "bail:", - " if (yyss)", - " free(yyss);", - " if (yyvs)", - " free(yyvs);", + " free(yyss);", + " free(yyvs);", " yyss = yyssp = NULL;", " yyvs = yyvsp = NULL;", " yystacksize = 0;", @@ -368,19 +364,15 @@ char *trailer[] = "yyoverflow:", " yyerror(\"yacc stack overflow\");", "yyabort:", - " if (yyss)", - " free(yyss);", - " if (yyvs)", - " free(yyvs);", + " free(yyss);", + " free(yyvs);", " yyss = yyssp = NULL;", " yyvs = yyvsp = NULL;", " yystacksize = 0;", " return (1);", "yyaccept:", - " if (yyss)", - " free(yyss);", - " if (yyvs)", - " free(yyvs);", + " free(yyss);", + " free(yyvs);", " yyss = yyssp = NULL;", " yyvs = yyvsp = NULL;", " yystacksize = 0;", |