Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 27299 invoked from network); 1 Sep 2010 10:16:42 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Sep 2010 10:16:42 -0000 Received: (qmail 11012 invoked by uid 500); 1 Sep 2010 10:16:41 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 10910 invoked by uid 500); 1 Sep 2010 10:16:38 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 10902 invoked by uid 99); 1 Sep 2010 10:16:37 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Sep 2010 10:16:37 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of minfrin@sharp.fm designates 72.32.122.20 as permitted sender) Received: from [72.32.122.20] (HELO chandler.sharp.fm) (72.32.122.20) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Sep 2010 10:16:13 +0000 Received: from chandler.sharp.fm (localhost [127.0.0.1]) by chandler.sharp.fm (Postfix) with ESMTP id D45782C8682 for ; Wed, 1 Sep 2010 05:15:51 -0500 (CDT) Received: from [10.0.0.251] (87-194-125-18.bethere.co.uk [87.194.125.18]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client did not present a certificate) (Authenticated sender: minfrin@sharp.fm) by chandler.sharp.fm (Postfix) with ESMTP id 76EFD2C8680 for ; Wed, 1 Sep 2010 05:15:51 -0500 (CDT) Message-Id: From: Graham Leggett To: dev@httpd.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: rational behind not checking the return value of apr_palloc and apr_pcalloc Date: Wed, 1 Sep 2010 12:15:49 +0200 References: X-Mailer: Apple Mail (2.936) X-Virus-Scanned: ClamAV using ClamSMTP X-Virus-Checked: Checked by ClamAV on apache.org On 01 Sep 2010, at 6:07 AM, dave b wrote: > What is the rational behind not checking the return value of > apr_palloc and apr_pcalloc? The rationale is to not be forced to check for and handle hundreds of potential failure cases when you're probably doomed anyway. The APR pools API gives you the apr_pool_abort_set() function, which specifies a function to call if the memory allocation fails. In the case of httpd, a function is registered which gracefully shuts down that particular server process if the allocation fails, and apr_palloc() is in the process guaranteed to never return NULL. Obviously if you're not using APR from httpd, or if you're writing a library that depends on APR, and you haven't set an abort function, NULL will potentially be returned and you should check for and handle that case. Regards, Graham --