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