]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibOptPei/CompareMemWrapper.c
1. Change 0 == Length style to Length == 0
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptPei / CompareMemWrapper.c
CommitLineData
7b3b4b29 1/** @file\r
2 CompareMem() implementation.\r
3\r
4 Copyright (c) 2006, Intel Corporation<BR>\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
2bfb6009 13 The following BaseMemoryLib instances contain the same copy of this file:\r
7b3b4b29 14\r
15 BaseMemoryLib\r
16 BaseMemoryLibMmx\r
17 BaseMemoryLibSse2\r
18 BaseMemoryLibRepStr\r
2bfb6009
LG
19 BaseMemoryLibOptDxe\r
20 BaseMemoryLibOptPei\r
7b3b4b29 21 PeiMemoryLib\r
22 DxeMemoryLib\r
23\r
24**/\r
25\r
1efcc4ae 26\r
7b3b4b29 27\r
28\r
29#include "MemLibInternals.h"\r
30\r
31/**\r
32 Compares the contents of two buffers.\r
33\r
34 This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.\r
35 If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the\r
36 value returned is the first mismatched byte in SourceBuffer subtracted from the first\r
37 mismatched byte in DestinationBuffer.\r
2bfb6009
LG
38 If Length > 0 and DestinationBuffer is NULL, then ASSERT().\r
39 If Length > 0 and SourceBuffer is NULL, then ASSERT().\r
7b3b4b29 40 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). \r
41 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). \r
42\r
43\r
44 @param DestinationBuffer Pointer to the destination buffer to compare.\r
45 @param SourceBuffer Pointer to the source buffer to compare.\r
46 @param Length Number of bytes to compare.\r
47\r
48 @return 0 All Length bytes of the two buffers are identical.\r
49 @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first\r
50 mismatched byte in DestinationBuffer.\r
51\r
52**/\r
53INTN\r
54EFIAPI\r
55CompareMem (\r
56 IN CONST VOID *DestinationBuffer,\r
57 IN CONST VOID *SourceBuffer,\r
58 IN UINTN Length\r
59 )\r
60{\r
cc4e0485 61 if (Length == 0 || DestinationBuffer == SourceBuffer) {\r
7b3b4b29 62 return 0;\r
63 }\r
64 ASSERT (DestinationBuffer != NULL);\r
65 ASSERT (SourceBuffer != NULL);\r
66 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r
67 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r
68\r
69 return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);\r
70}\r