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
n
bytes in size.source – The source buffer. Up to
n
bytes will be copied.n – The maximum number of characters of
source
to copy todest
. If noNUL
character was encountered in the firstn - 1
characters ofsource
, thendest[n - 1]
will be aNUL
character. This is a departure fromstrncpy()
but similar tostrncpy_s()
.
- Returns
true
if the memory was successfully copied;false
otherwise. Iffalse
is returned,dest
is in a valid but undefined state.