diff options
author | obrien <obrien@FreeBSD.org> | 2001-07-24 14:05:21 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2001-07-24 14:05:21 +0000 |
commit | 6dc73139c0963b16a0a8642e6399a5433348138e (patch) | |
tree | 5cfbf3a709a30e3188c47d1beb93d8b2481dcaf0 /usr.bin/sed/process.c | |
parent | 4f82093ece0a22bfe072a2c476f29289a0773290 (diff) | |
download | FreeBSD-src-6dc73139c0963b16a0a8642e6399a5433348138e.zip FreeBSD-src-6dc73139c0963b16a0a8642e6399a5433348138e.tar.gz |
Expand xmalloc in-place, along with xrealloc; which wasn't even ANSI in its
implementation.
Diffstat (limited to 'usr.bin/sed/process.c')
-rw-r--r-- | usr.bin/sed/process.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index 77ef93a..baad0f1 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -113,9 +113,10 @@ redirect: goto redirect; case 'a': if (appendx >= appendnum) - appends = xrealloc(appends, + if ((appends = realloc(appends, sizeof(struct s_appends) * - (appendnum *= 2)); + (appendnum *= 2))) == NULL) + err(1, "realloc"); appends[appendx].type = AP_STRING; appends[appendx].s = cp->t; appends[appendx].len = strlen(cp->t); @@ -201,9 +202,10 @@ redirect: exit(0); case 'r': if (appendx >= appendnum) - appends = xrealloc(appends, + if ((appends = realloc(appends, sizeof(struct s_appends) * - (appendnum *= 2)); + (appendnum *= 2))) == NULL) + err(1, "realloc"); appends[appendx].type = AP_FILE; appends[appendx].s = cp->t; appends[appendx].len = strlen(cp->t); @@ -548,7 +550,9 @@ regsub(sp, string, src) #define NEEDSP(reqlen) \ if (sp->len >= sp->blen - (reqlen) - 1) { \ sp->blen += (reqlen) + 1024; \ - sp->space = sp->back = xrealloc(sp->back, sp->blen); \ + if ((sp->space = sp->back = realloc(sp->back, sp->blen)) \ + == NULL) \ + err(1, "realloc"); \ dst = sp->space + sp->len; \ } @@ -596,7 +600,9 @@ cspace(sp, p, len, spflag) tlen = sp->len + len + 1; if (tlen > sp->blen) { sp->blen = tlen + 1024; - sp->space = sp->back = xrealloc(sp->back, sp->blen); + if ((sp->space = sp->back = realloc(sp->back, sp->blen)) == + NULL) + err(1, "realloc"); } if (spflag == REPLACE) |