X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FBaseMemoryLibMmx%2FCopyMemWrapper.c;h=1fd00acabd531e5f82bedd49f8cc042bf8f58557;hp=5ca62f50478428426398688c405bb399231eaa7b;hb=24e25d11c0460dfb39fade685375c0e58cbcb40e;hpb=23f52b03b4202e4dc5af440a90f0b0864a45dbdd diff --git a/MdePkg/Library/BaseMemoryLibMmx/CopyMemWrapper.c b/MdePkg/Library/BaseMemoryLibMmx/CopyMemWrapper.c index 5ca62f5047..1fd00acabd 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/CopyMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/CopyMemWrapper.c @@ -26,41 +26,37 @@ #include "MemLibInternals.h" /** - Copy Length bytes from Source to Destination. + Copies a source buffer to a destination buffer, and returns the destination buffer. - This function copies Length bytes from SourceBuffer to DestinationBuffer, and - returns DestinationBuffer. The implementation must be reentrant, and it must - handle the case where SourceBuffer overlaps DestinationBuffer. + This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns + DestinationBuffer. The implementation must be reentrant, and it must handle the case + where SourceBuffer overlaps DestinationBuffer. + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). - If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then - ASSERT(). - If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + @param DestinationBuffer Pointer to the destination buffer of the memory copy. + @param SourceBuffer Pointer to the source buffer of the memory copy. + @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer. - @param Destination Target of copy - @param Source Place to copy from - @param Length Number of bytes to copy - - @return Destination + @return DestinationBuffer. **/ VOID * EFIAPI CopyMem ( - OUT VOID *Destination, - IN CONST VOID *Source, - IN UINTN Length + OUT VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length ) { - ASSERT ( - Destination == NULL || - Length <= MAX_ADDRESS - (UINTN)Destination + 1 - ); - ASSERT ( - Source == NULL || - Length <= MAX_ADDRESS - (UINTN)Source + 1 - ); - if (Destination == Source || Length == 0) { - return Destination; + if (Length == 0) { + return DestinationBuffer; + } + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer)); + + if (DestinationBuffer == SourceBuffer) { + return DestinationBuffer; } - return InternalMemCopyMem (Destination, Source, Length); + return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length); }