• alloc() can’t fail, afree() can take NULL

‣ macro afreechk() is superfluous
• get rid of macro afreechv() by re-doing the “don’t leak that much” code
• some KNF (mostly, whitespace and 80c) while here
This commit is contained in:
tg
2008-05-17 18:47:03 +00:00
parent b41a72ac2e
commit f17b8b1c8b
14 changed files with 77 additions and 93 deletions

9
lex.c
View File

@@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.59 2008/05/04 01:51:30 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.60 2008/05/17 18:46:59 tg Exp $");
/*
* states while lexing word
@@ -774,7 +774,8 @@ yylex(int cf)
if ((c == '<' || c == '>') && state == SBASE &&
((c2 = Xlength(ws, wp)) == 0 ||
(c2 == 2 && dp[0] == CHAR && ksh_isdigit(dp[1])))) {
struct ioword *iop = (struct ioword *) alloc(sizeof(*iop), ATEMP);
struct ioword *iop = (struct ioword *)alloc(sizeof (*iop),
ATEMP);
if (c2 == 2)
iop->unit = dp[1] - '0';
@@ -1012,7 +1013,7 @@ pushs(int type, Area *areap)
{
Source *s;
s = (Source *)alloc(sizeof(Source), areap);
s = (Source *)alloc(sizeof (Source), areap);
s->type = type;
s->str = null;
s->start = NULL;
@@ -1501,7 +1502,7 @@ getsc_bn(void)
static Lex_state *
push_state_(State_info *si, Lex_state *old_end)
{
Lex_state *new = alloc(sizeof(Lex_state) * STATE_BSIZE, ATEMP);
Lex_state *new = alloc(sizeof (Lex_state) * STATE_BSIZE, ATEMP);
new[0].ls_info.base = old_end;
si->base = &new[0];