• 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:
10
eval.c
10
eval.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.45 2008/03/01 22:49:37 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.46 2008/05/17 18:46:58 tg Exp $");
|
||||
|
||||
#ifdef MKSH_SMALL
|
||||
#define MKSH_NOPWNAM
|
||||
@ -297,8 +297,8 @@ expand(const char *cp, /* input word */
|
||||
if (!st->next) {
|
||||
SubType *newst;
|
||||
|
||||
newst = (SubType *) alloc(
|
||||
sizeof(SubType), ATEMP);
|
||||
newst = (SubType *)alloc(
|
||||
sizeof (SubType), ATEMP);
|
||||
newst->next = NULL;
|
||||
newst->prev = st;
|
||||
st->next = newst;
|
||||
@ -589,7 +589,7 @@ expand(const char *cp, /* input word */
|
||||
*/
|
||||
len = strlen(dp) + 1;
|
||||
setstr(st->var,
|
||||
debunk((char *) alloc(len, ATEMP),
|
||||
debunk((char *)alloc(len, ATEMP),
|
||||
dp, len), KSH_UNWIND_ERROR);
|
||||
x.str = str_val(st->var);
|
||||
type = XSUB;
|
||||
@ -1474,7 +1474,7 @@ alt_expand(XPtrV *wp, char *start, char *exp_start, char *end, int fdo)
|
||||
l1 = brace_start - start;
|
||||
l2 = (p - 1) - field_start;
|
||||
l3 = end - brace_end;
|
||||
new = (char *) alloc(l1 + l2 + l3 + 1, ATEMP);
|
||||
new = (char *)alloc(l1 + l2 + l3 + 1, ATEMP);
|
||||
memcpy(new, start, l1);
|
||||
memcpy(new + l1, field_start, l2);
|
||||
memcpy(new + l1 + l2, brace_end, l3);
|
||||
|
Reference in New Issue
Block a user