Re: Unexpected usage of 'duplicate' flag in sapi_add_header_ex()
| From: | Antony Dovgal | Date: | Tue, 03 Apr 2007 18:37:00 +0000 |
| Subject: | Re: Unexpected usage of 'duplicate' flag in sapi_add_header_ex() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-28659@lists.php.net to get a copy of this message | ||
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)Apparently yes.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?
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