You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by William A Rowe Jr <wr...@rowe-clan.net> on 2015/08/27 17:06:32 UTC
Re: svn commit: r1698133 - in /httpd/httpd/trunk: include/httpd.h
modules/http2/h2_switch.c server/protocol.c server/util.c
On Aug 27, 2015 7:14 AM, <ic...@apache.org> wrote:
>
> Author: icing
> Date: Thu Aug 27 12:13:59 2015
> New Revision: 1698133
>
> URL: http://svn.apache.org/r1698133
> Log:
> giving ap_array_index a start parameter, adding ap_array_contains
>
> */
> -AP_DECLARE(int) ap_array_index(const apr_array_header_t *array, const
char *s);
> +AP_DECLARE(int) ap_array_index(const apr_array_header_t *array,
> + const char *s,
> + apr_size_t start);
You want the type of rv of _index to correspond to the start input to rv,
no? E.g.
int n = -1, count = 0;
while ((n = ap_array_index(arr, findtag, n + 1)) >= 0)
++count;
sizeof(int) does not have to equal sizeof(apr_size_t). But for indexes I
believe it's fine. The alternative is apr_ssize_t for both start arg and
rv.
Re: svn commit: r1698133 - in /httpd/httpd/trunk: include/httpd.h
modules/http2/h2_switch.c server/protocol.c server/util.c
Posted by Yann Ylavic <yl...@gmail.com>.
On Thu, Aug 27, 2015 at 5:06 PM, William A Rowe Jr <wr...@rowe-clan.net> wrote:
>
> On Aug 27, 2015 7:14 AM, <ic...@apache.org> wrote:
>>
>> Author: icing
>> Date: Thu Aug 27 12:13:59 2015
>> New Revision: 1698133
>>
>> URL: http://svn.apache.org/r1698133
>> Log:
>> giving ap_array_index a start parameter, adding ap_array_contains
>>
>
>> */
>> -AP_DECLARE(int) ap_array_index(const apr_array_header_t *array, const
>> char *s);
>> +AP_DECLARE(int) ap_array_index(const apr_array_header_t *array,
>> + const char *s,
>> + apr_size_t start);
>
> You want the type of rv of _index to correspond to the start input to rv,
> no? E.g.
>
> int n = -1, count = 0;
> while ((n = ap_array_index(arr, findtag, n + 1)) >= 0)
> ++count;
>
> sizeof(int) does not have to equal sizeof(apr_size_t). But for indexes I
> believe it's fine. The alternative is apr_ssize_t for both start arg and
> rv.
Or use the same type as array->nelts: int?
The conversion from unsigned to signed and (possible) sizeof mixing
looks incorrect to me.
Also, maybe ap_array_string_index would be a better name since arrays
contain any pointer (likewise
s/ap_array_contains/ap_array_has_string/g).
We could then create new ones for other types when/if necessary (or
add them to APR by appending a single r :)