Closed CvRXX closed 6 years ago
AIUI, end()
may point to unallocated memory when the string is not constructed from a null-terminated string. As such dereferencing it is probably a bad idea.
I would suggest checking the content lengths of each string and leaving the rest of the comparison function unchanged from @ManDeJan's version. (edit: nvm, must work with const char*
as rhs too, and checking the length would be unnecessarily expensive)
Thanks, I fixed it by comparing pointers instead of values. @cjsmeele could you confirm that this is correct?
Can't test it but it looks good to me :-)
Wouter fixed it :-p
The == of the
hwlib::string
would never find a'\0'
in his own string so I changed it to check for the end pointer.