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.

As with memmove(), the memory areas may overlap: copying takes place as though the bytes in source are first copied into a temporary array that does not overlap source or dest, and the bytes are then copied from the temporary array to dest.
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 to dest.

Returns

true if the memory was successfully copied. If false is returned, dest is in a valid but undefined state.