On Fri, Jan 20, 2023 at 9:32 AM Ted Yu <yuzhih...@gmail.com> wrote: > > Since `validIdentifier` doesn't modify the contents of `name` string, it > seems that there is no need to create `tmp` string in `validNamedOperator`. > You can pass the start and end offsets into the string (name) as second and > third parameters to `validIdentifier`.
Thanks for reviewing the patch! I was making a temporary copy of the string, since I had to modify it before the validation, whereas the callee expects a `const char*`. I agree that the same check can be done with more elegance, while eliminating the temporary allocation. Please find the updated patch attached. Instead of passing the start and end of region I want to check, as suggested, I'm now passing just the length of the string I want validated. But I think that's for the better, since it now aligns with the comment that validIdentifier() does not check if the passed string is shorter than NAMEDATALEN. Best regards, Gurjeet http://Gurje.et
named_operators_v4.patch
Description: Binary data