On 10/28/2011 09:55 AM, Kinkie wrote:
> +/**
> + * look for the last occurrence of a character in a c-string with a set maximum length
> + */
> +SQUIDCEXTERN const char *strnrchr(const char *s, size_t slen, char c);
> +
"Maximum c-string length" oxymoron allows for at least two very
different interpretations as illustrated below:
Your strnrchr() implementation implies the following specs: "find the
last character c before the end of the string or slen-th string
character, whichever comes first". These specs costs a lot of wasted
cycles in most cases because you have to start looking from the
beginning of the string and check for null character at each position.
However, the actual use in the patch implies we can just use memrchr()
instead, which is much more efficient, of course.
Can we just use memrchr() instead (and provide it if it is not available)?
> + if (!((target = strnrchr (item, initiallen+1, ';')) && ...
Why are we adding 1 in the above strnrchr() call? Does not the item have
no more than initiallen characters?
Thank you,
Alex.
Received on Fri Oct 28 2011 - 20:05:41 MDT
This archive was generated by hypermail 2.2.0 : Mon Oct 31 2011 - 12:00:08 MDT