]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibRepStr/CompareMemWrapper.c
1. Change 0 == Length style to Length == 0
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibRepStr / CompareMemWrapper.c
1 /** @file
2 CompareMem() 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 The following BaseMemoryLib instances contain the same copy of this file:
14
15 BaseMemoryLib
16 BaseMemoryLibMmx
17 BaseMemoryLibSse2
18 BaseMemoryLibRepStr
19 BaseMemoryLibOptDxe
20 BaseMemoryLibOptPei
21 PeiMemoryLib
22 DxeMemoryLib
23
24 **/
25
26
27
28
29 #include "MemLibInternals.h"
30
31 /**
32 Compares the contents of two buffers.
33
34 This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.
35 If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the
36 value returned is the first mismatched byte in SourceBuffer subtracted from the first
37 mismatched byte in DestinationBuffer.
38 If Length > 0 and DestinationBuffer is NULL, then ASSERT().
39 If Length > 0 and SourceBuffer is NULL, then ASSERT().
40 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
41 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
42
43
44 @param DestinationBuffer Pointer to the destination buffer to compare.
45 @param SourceBuffer Pointer to the source buffer to compare.
46 @param Length Number of bytes to compare.
47
48 @return 0 All Length bytes of the two buffers are identical.
49 @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
50 mismatched byte in DestinationBuffer.
51
52 **/
53 INTN
54 EFIAPI
55 CompareMem (
56 IN CONST VOID *DestinationBuffer,
57 IN CONST VOID *SourceBuffer,
58 IN UINTN Length
59 )
60 {
61 if (Length == 0 || DestinationBuffer == SourceBuffer) {
62 return 0;
63 }
64 ASSERT (DestinationBuffer != NULL);
65 ASSERT (SourceBuffer != NULL);
66 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));
67 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));
68
69 return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);
70 }