Eric Blake <[EMAIL PROTECTED]> writes:

> +  size_t *table = (size_t *) malloca (m * sizeof (size_t));
> +  if (table == NULL)
> +    return false;

Shouldn't this check for overflow in the multiplication?
Something like this, perhaps?

   size_t *table;
   if (xalloc_oversized (m, sizeof *table))
     return false;
   table = (size_t *) malloca (m * sizeof *table);
   if (table == NULL)
     return false;

> +     unsigned char b = (unsigned char) needle[i - 1];
> ...
> +         if (b == (unsigned char) needle[j])

Would it be cleaner to declare 'b' to be of type 'char' and avoid the
casts?

> +      if ((unsigned char) needle[j] == (unsigned char) *phaystack)

Can both casts be omitted?

> +    return memchr (haystack, (unsigned char) *Needle, haystack_len);

Can the cast be omitted?

> +    return (void *) haystack;

How about "return Haystack;"?  That avoids a cast.

(As you can tell, I prefer to avoid casts....)

> +  if (needle_len == 0)

Perhaps a __builtin_expect would be helpful here?


Reply via email to