From owner-freebsd-hackers Sun Jan 12 14:51:40 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id OAA29133 for hackers-outgoing; Sun, 12 Jan 1997 14:51:40 -0800 (PST) Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id OAA29128 for ; Sun, 12 Jan 1997 14:51:37 -0800 (PST) Received: (from uucp@localhost) by sax.sax.de (8.6.12/8.6.12-s1) with UUCP id XAA27774 for hackers@FreeBSD.org; Sun, 12 Jan 1997 23:51:29 +0100 Received: (from j@localhost) by uriah.heep.sax.de (8.8.4/8.6.9) id XAA07469; Sun, 12 Jan 1997 23:23:33 +0100 (MET) Message-ID: 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 References: <199701122149.OAA26408@phaeton.artisoft.com> X-Mailer: Mutt 0.55-PL10 Mime-Version: 1.0 X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <199701122149.OAA26408@phaeton.artisoft.com>; from Terry Lambert on Jan 12, 1997 14:49:57 -0700 Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk 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. ;-)