3 ms·
It's also worth pointing out that buffers passed to strcpy, memcpy, etc. must not overlap. Otherwise it results in undefined behavior.
by grn 14y ago
It's also worth pointing out that buffers passed to strcpy, memcpy, etc. must not overlap. Otherwise it results in undefined behavior.
- lttlrck 14y agoThat's stdlib though, not the language.
- caf 14y agoThe standard library is part of the language - all hosted implementations must provide it. This allows, for example, compilers to replace a `memcpy()` call that has a constant size argument with direct loads/stores.
- apaprocki 14y agoIt has come up in the past that this distinction is a historical artifact rather than a necessity. Linus tried to get Ulrich to change this in glibc, but it was not changed. http://www.sourceware.org/bugzilla/show_bug.cgi?id=12518 http://www.sourceware.org/bugzilla/show_bug.cgi?id=12518
- angersock 14y agomemmove() has proper memory moving semantics, and can deal with overlapping buffers.