Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Jan 1997 23:23:32 +0100
From:      j@uriah.heep.sax.de (J Wunsch)
To:        hackers@FreeBSD.org
Subject:   Re: number of lines in a file, given its size
Message-ID:  <Mutt.19970112232332.j@uriah.heep.sax.de>
In-Reply-To: <199701122149.OAA26408@phaeton.artisoft.com>; from Terry Lambert on Jan 12, 1997 14:49:57 -0700
References:  <Mutt.19970112214937.j@uriah.heep.sax.de> <199701122149.OAA26408@phaeton.artisoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
As Terry Lambert wrote:

> I think erroring out to "okshells" on the malloc failure is a bit
> bogus...

malloc errors are bogus, too. :)  The hell will break afterwards
anyway, so it doesn't matter whether it returns `okshells' or
something else.

> Wouldn'tr it be better to allocate the full file size, and strtok the
> \n's to nulls, and terminate with a double null instead?

That's an idea.  I think noting down the pointers makes it easier to
compare the strings later, but still, it could take this as an
occasion to count the actual lines, and allocate the pointer to string
array accordingly.

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Mutt.19970112232332.j>