Re: [PATCH v2 3/6] match_basename: use strncmp instead of strcmp
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 10, 2013, 12:14 UTC
- Message-ID
- <CACsJy8C+29ebL37kFC21S-b670-ct2yCOjghLPErjwXz1BoQBA@mail.gmail.com>
- In-Reply-To
- <CALWbr2w+HdsOJAXF3974=vx+BtxgCC=bKHetE=ptXTwv7_L0pg@mail.gmail.com>
On Sun, Mar 10, 2013 at 7:11 PM, Antoine Pelisse <apelisse@gmail.com> wrote:
Show 11 quoted lines
>>> By the way, if we know the length of the string, we could use memcmp. >>> This one is allowed to compare 4-bytes at a time (he doesn't care >>> about end of string). This is true because the value of the length >>> parameter is no longer "at most". >> >> We still need to worry about access violation after NUL when two >> strings have different lengths. That could be avoided in this >> particular case, but I think it's too fragile. > > Why would we need to compare if the strings don't have the same length > ? We already do that in combine-diff.c:append_lost().
Watching movie and replying to git@ don't mix. You're right we don't need to compare if lengths are different. What was I thinking..
-- Duy