From owner-freebsd-hackers Wed Jul 7 14: 2:47 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id 663C314F0B for ; Wed, 7 Jul 1999 14:02:38 -0700 (PDT) (envelope-from des@flood.ping.uio.no) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.1) id XAA93574; Wed, 7 Jul 1999 23:01:13 +0200 (CEST) (envelope-from des) To: Assar Westerlund Cc: Dag-Erling Smorgrav , Jamie Howard , freebsd-hackers@FreeBSD.ORG, tech-userlevel@netbsd.org, tech@openbsd.org Subject: Re: Replacement for grep(1) (part 2) References: <5laet8b2l8.fsf@assaris.sics.se> From: Dag-Erling Smorgrav Date: 07 Jul 1999 23:01:13 +0200 In-Reply-To: Assar Westerlund's message of "07 Jul 1999 22:57:07 +0200" Message-ID: Lines: 27 X-Mailer: Gnus v5.5/Emacs 19.34 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Assar Westerlund writes: > Dag-Erling Smorgrav writes: > > + realpat = grep_malloc(strlen(pattern) + sizeof("^(") > > + + sizeof(")$") + 1); > Why not just use asprintf? Doesn't matter, thsis code is gone in the latest version. You though the linux 'kernel of the day' was bad; now you have the FreeBSD 'grep of the minute' :) > In this case it doesn't matter but in general this function is wrong. > malloc(0) can return NULL. Agreed. > And besides, I really don't think this is a grep function but actually > is useful for programs that don't have any strategy for handling out > of memory errors and might as well die (with a descriptive error > message, of course). Let's call it emalloc and let's put in somewhere > where it can be used. Too simple to warrant that, and other programs will likely want to handle the error differently. DES -- Dag-Erling Smorgrav - des@flood.ping.uio.no To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message