summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseMemoryLibRepStr/CopyMemWrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/BaseMemoryLibRepStr/CopyMemWrapper.c')
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/CopyMemWrapper.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/CopyMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/CopyMemWrapper.c
index 5ca62f5..1fd00ac 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/CopyMemWrapper.c
+++ b/MdePkg/Library/BaseMemoryLibRepStr/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);
}