From owner-freebsd-hackers Sun Jan 12 11:21:52 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id LAA12147 for hackers-outgoing; Sun, 12 Jan 1997 11:21:52 -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 LAA12113 for ; Sun, 12 Jan 1997 11:21:43 -0800 (PST) Received: (from uucp@localhost) by sax.sax.de (8.6.12/8.6.12-s1) with UUCP id UAA23006 for hackers@freebsd.org; Sun, 12 Jan 1997 20:21:41 +0100 Received: (from j@localhost) by uriah.heep.sax.de (8.8.4/8.6.9) id TAA01160; Sun, 12 Jan 1997 19:57:25 +0100 (MET) Message-ID: Date: Sun, 12 Jan 1997 19:57:25 +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: <199701121833.LAA25809@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: <199701121833.LAA25809@phaeton.artisoft.com>; from Terry Lambert on Jan 12, 1997 11:33:06 -0700 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk As Terry Lambert wrote: > > > strdup() to the rescue! ... > > > > Failed. Try again. UTSL first. > > J"org, you are downright diabolical... > > Obviously, I wasn't citing code in this case, only a method of functional > decomposition. But you've got your point wrong. strdup(), as much you prefer it or not, was _by no means_ the answer to the question. The question was how much space to allocate for the pointers you get from strdup() or whatever has been chosen. You can solve this problem with realloc(), but it seems that the existing solution is, though dirty, much less overkill. -- 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. ;-)