Doug MacEachern wrote:

does this:
   end = memchr(s, '\0', n);
   if (end != NULL)
       n = end - s;

is that just  to avoid allocating an extra byte if 's' already contains
'\0' at the end?  seem like it would be better to waste the extra byte
than to scan the whole string with memchr() or at least change that to:
   if (*(s + (n-1)) == '\0') {
       n--;
   }


There's no guarantee that strlen(s) is anywhere near n. It's valid for a caller to do this, for example: apr_pstrndup(p, "foo", 65536);

--Brian





Reply via email to