SirDice said:One of the great things about FreeBSD is that you can take a look at the source code.
http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/tail/
while ((ch = getc(fp)) != EOF) {
...
if ((sp = realloc(sp, blen += 1024)) == NULL)
...
if ((llines[recno].l = realloc(llines[recno].l,
.....
if (ferror(fp)) {
ierr(fn);
rc = 1;
goto done;
}
....
}
done:
for (cnt = 0; cnt < off; cnt++)
[color="Red"] free(llines[cnt].l);
free(sp);[/color]