This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Passing 0 for number of bytes to be scanned in memchr


Hi Jonathan,
I see that in char_traits<char>::find, we check if the number  of bytes to be scanned is zero. I think memchr handles that case already  but I do not have 
any reference to point out to. The documentation does not explicitly  mention what happens when 'n' is zero. If n==0 is already handled then
we can safely remove this check. Please let me know your thoughts.



269       static const char_type*
270       find(const char_type* __s, size_t __n, const char_type& __a)
271       {
272         if (__n == 0)
273           return 0;
274         return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n));
275       }

Thanks,
-Aditya


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]