protectedStrncpy#
Fully qualified name: carb::memory::protectedStrncpy
Defined in carb/memory/Util.h
- inline bool carb::memory::protectedStrncpy(
- char *dest,
- const char *source,
- size_t n,
Copies memory as via strncpy, but returns false if an access violation occurs while reading.
- Thread Safety
This function is safe to call concurrently. However, this function makes no guarantees about the consistency of data copied when the data is modified while copied, only the attempting to read invalid memory will not result in an access violation.
Warning
This function is designed for safety, not performance, and may be very slow to execute.
Warning
The source and dest buffers may not overlap.
- Parameters:
dest – The destination buffer that will receive the memory. Must be at least
nbytes in size.source – The source buffer. Up to
nbytes will be copied.n – The maximum number of characters of
sourceto copy todest. If noNULcharacter was encountered in the firstn - 1characters ofsource, thendest[n - 1]will be aNULcharacter. This is a departure fromstrncpy()but similar tostrncpy_s().
- Returns:
trueif the memory was successfully copied;falseotherwise. Iffalseis returned,destis in a valid but undefined state.