]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibMmx/CopyMemWrapper.c
1. Change 0 == Length style to Length == 0
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibMmx / CopyMemWrapper.c
1 /** @file
2 CopyMem() implementation.
3
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 Module Name: CopyMemWrapper.c
14
15 The following BaseMemoryLib instances contain the same copy of this file:
16
17 BaseMemoryLib
18 BaseMemoryLibMmx
19 BaseMemoryLibSse2
20 BaseMemoryLibRepStr
21 BaseMemoryLibOptDxe
22 BaseMemoryLibOptPei
23 PeiMemoryLib
24 DxeMemoryLib
25
26 **/
27
28 #include "MemLibInternals.h"
29
30 /**
31 Copies a source buffer to a destination buffer, and returns the destination buffer.
32
33 This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns
34 DestinationBuffer. The implementation must be reentrant, and it must handle the case
35 where SourceBuffer overlaps DestinationBuffer.
36 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
37 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
38
39 @param DestinationBuffer Pointer to the destination buffer of the memory copy.
40 @param SourceBuffer Pointer to the source buffer of the memory copy.
41 @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer.
42
43 @return DestinationBuffer.
44
45 **/
46 VOID *
47 EFIAPI
48 CopyMem (
49 OUT VOID *DestinationBuffer,
50 IN CONST VOID *SourceBuffer,
51 IN UINTN Length
52 )
53 {
54 if (Length == 0) {
55 return DestinationBuffer;
56 }
57 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));
58 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));
59
60 if (DestinationBuffer == SourceBuffer) {
61 return DestinationBuffer;
62 }
63 return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length);
64 }