The difference between rtlcopymemory and RtlMoveMemory

Source: Internet
Author: User

Both Rtlcopymemory and rtlmovememory are memory replicas. The difference is that rtlcopymemory non-overlapping replication, while rtlmovememory is overlapping replication, what exactly does that mean? The specific explanations are as follows:

ABCD represents the start and end addresses of the three-segment memory, respectively. If you need to copy the A-to-C memory into the B-to-D memory, this is the memory of the B-to-c segment, which is the overlapping part. The internal implementation of the Rtlcopymemory function is based on the memcpy function. According to the C99 definition, memcpy does not consider overlapping portions, so he cannot guarantee that overlapping parts will be duplicated. In order to ensure that overlapping parts are also copied correctly, C99 specifies that the Memmove function accomplishes this task. This function determines whether or not two memory overlaps, and this judgment sacrifices the speed.

If the programmer can ensure that the copied memory does not overlap, select Use memcpy. If it is not guaranteed, choose to use the Memmove function. To ensure portability, DDK uses macros to encapsulate these two functions, namely: Rtlcopymemory and RtlMoveMemory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.