carb::memory::protectedMemmove
Defined in carb/memory/Util.h
-
inline bool carb::memory::protectedMemmove(void *dest, const void *source, size_t len)
Copies memory as via memmove, but returns false if a read access violation occurs while reading.
memmove()
, the memory areas may overlap: copying takes place as though the bytes insource
are first copied into a temporary array that does not overlapsource
ordest
, and the bytes are then copied from the temporary array todest
.- 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 protection, not performance, and may be very slow to execute.
- Parameters
dest – The destination buffer that will receive the copied bytes.
source – The source buffer to copy bytes from.
len – The number of bytes of
source
to copy todest
.
- Returns
true
if the memory was successfully copied. Iffalse
is returned,dest
is in a valid but undefined state.