Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28659 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98586 invoked by uid 1010); 3 Apr 2007 18:37:06 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 98565 invoked from network); 3 Apr 2007 18:37:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2007 18:37:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=antony@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=antony@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: antony@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from [212.25.124.162] ([212.25.124.162:25038] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/C9-17495-FCE92164 for ; Tue, 03 Apr 2007 14:37:05 -0400 Received: (qmail 6175 invoked from network); 3 Apr 2007 18:36:59 -0000 Received: from internal.zend.office (HELO ?127.0.0.1?) (10.1.1.1) by internal.zend.office with SMTP; 3 Apr 2007 18:36:59 -0000 Message-ID: <46129ECC.4010402@zend.com> Date: Tue, 03 Apr 2007 22:37:00 +0400 User-Agent: Thunderbird 2.0b2 (X11/20070116) MIME-Version: 1.0 To: js CC: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Unexpected usage of 'duplicate' flag in sapi_add_header_ex() From: antony@zend.com (Antony Dovgal) On 04/03/2007 07:26 PM, js wrote: > Hi gurus. > > Fiddling with PHP extensions I found the following code in > 'sapi_add_header_ex()' in SAPI.c > > if (!duplicate) > efree(header_line); > > which makes me wonder because the other day I read CODING_STANDARD > included in PHP src which says > > "[1] Functions that are given pointers to resources should not free them > *snip* > Exceptions: > - The function's designated behavior is freeing that resource. E.g. efree() > - The function is given a boolean argument, that controls whether or not > the function may free its arguments (if true - the function must free its > arguments, if false - it must not) > *snip* > " > I felt the rule above is incompatible with how efree and duplicate > flag is used in > sapi_add_header_ex(). > > So my question is... > Is this intentional? Apparently yes. > If so, any reason to break the coding standard in this instance? Standards are general rules, there might be some exceptions. (It doesn't mean I personally like this code or encourage to ignore the standards). > and what does, in this context, 'duplicate' means? See main/main.c, line 1119 for example. It might be convenient to free duplicated buffer and ignore static one. -- Wbr, Antony Dovgal