3 ms·
The fact that he calls it "Memcopy()" doesn't exactly lend confidence. I don't really see the problem with memcpy() anyway: memcpy() copies exactly the given nu
by neilc 17y ago
The fact that he calls it "Memcopy()" doesn't exactly lend confidence. I don't really see the problem with memcpy() anyway: memcpy() copies exactly the given number of bytes. If the programmer gets the source buffer length wrong with memcpy(), they are just as likely to get the destination buffer length wrong with memcpy_s().
And banning strlen() is just idiotic. The differences between strlen() and strnlen_s() (the suggested "safe" replacement) are apparently: (1) strnlen_s() takes a maximum string length argument (2) strnlen_s() returns 0 on a NULL pointer. #1 is pointless (what if the string has no predefined maximum length), and will just lead to programmers hardcoding inappropriate constants. #2 is potentially hazardous, because it hides problems: NULL and the empty string are not the same thing, so having strnlen_s() return 0 for both cases is misleading.