]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiMemoryLib/MemLibGeneric.c
Add check before use to make code run more safer.
[mirror_edk2.git] / MdePkg / Library / PeiMemoryLib / MemLibGeneric.c
index f68272f2ae2801b4289a6e704020de4e8c44bdae..53f1cafa42adcddc101c11d7600ac56305703dd7 100644 (file)
@@ -6,7 +6,7 @@
     PeiMemoryLib\r
     UefiMemoryLib\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -26,7 +26,7 @@
   @param  Length  The count of 16-bit value to fill.\r
   @param  Value   The value with which to fill Length bytes of Buffer.\r
 \r
-  @return Buffer\r
+  @return Buffer.\r
 \r
 **/\r
 VOID *\r
@@ -50,7 +50,7 @@ InternalMemSetMem16 (
   @param  Length  The count of 32-bit value to fill.\r
   @param  Value   The value with which to fill Length bytes of Buffer.\r
 \r
-  @return Buffer\r
+  @return Buffer.\r
 \r
 **/\r
 VOID *\r
@@ -74,7 +74,7 @@ InternalMemSetMem32 (
   @param  Length  The count of 64-bit value to fill.\r
   @param  Value   The value with which to fill Length bytes of Buffer.\r
 \r
-  @return Buffer\r
+  @return Buffer.\r
 \r
 **/\r
 VOID *\r
@@ -94,10 +94,10 @@ InternalMemSetMem64 (
 /**\r
   Set Buffer to 0 for Size bytes.\r
 \r
-  @param  Buffer Memory to set.\r
+  @param  Buffer The memory to set.\r
   @param  Length The number of bytes to set\r
 \r
-  @return Buffer\r
+  @return Buffer.\r
 \r
 **/\r
 VOID *\r
@@ -113,9 +113,9 @@ InternalMemZeroMem (
 /**\r
   Compares two memory buffers of a given length.\r
 \r
-  @param  DestinationBuffer First memory buffer\r
-  @param  SourceBuffer      Second memory buffer\r
-  @param  Length            Length of DestinationBuffer and SourceBuffer memory\r
+  @param  DestinationBuffer The first memory buffer\r
+  @param  SourceBuffer      The second memory buffer\r
+  @param  Length            The length of DestinationBuffer and SourceBuffer memory\r
                             regions to compare. Must be non-zero.\r
 \r
   @return 0                 All Length bytes of the two buffers are identical.\r
@@ -147,7 +147,7 @@ InternalMemCompareMem (
   @param  Length  The count of 8-bit value to scan. Must be non-zero.\r
   @param  Value   The value to search for in the target buffer.\r
 \r
-  @return The pointer to the first occurrence or NULL if not found.\r
+  @return The pointer to the first occurrence, or NULL if not found.\r
 \r
 **/\r
 CONST VOID *\r
@@ -163,7 +163,7 @@ InternalMemScanMem8 (
   Pointer = (CONST UINT8*)Buffer;\r
   do {\r
     if (*(Pointer++) == Value) {\r
-      return Pointer;\r
+      return --Pointer;\r
     }\r
   } while (--Length != 0);\r
   return NULL;\r
@@ -177,7 +177,7 @@ InternalMemScanMem8 (
   @param  Length  The count of 16-bit value to scan. Must be non-zero.\r
   @param  Value   The value to search for in the target buffer.\r
 \r
-  @return The pointer to the first occurrence or NULL if not found.\r
+  @return The pointer to the first occurrence, or NULL if not found.\r
 \r
 **/\r
 CONST VOID *\r
@@ -193,7 +193,7 @@ InternalMemScanMem16 (
   Pointer = (CONST UINT16*)Buffer;\r
   do {\r
     if (*(Pointer++) == Value) {\r
-      return Pointer;\r
+      return --Pointer;\r
     }\r
   } while (--Length != 0);\r
   return NULL;\r
@@ -207,7 +207,7 @@ InternalMemScanMem16 (
   @param  Length  The count of 32-bit value to scan. Must be non-zero.\r
   @param  Value   The value to search for in the target buffer.\r
 \r
-  @return The pointer to the first occurrence or NULL if not found.\r
+  @return The pointer to the first occurrence, or NULL if not found.\r
 \r
 **/\r
 CONST VOID *\r
@@ -223,7 +223,7 @@ InternalMemScanMem32 (
   Pointer = (CONST UINT32*)Buffer;\r
   do {\r
     if (*(Pointer++) == Value) {\r
-      return Pointer;\r
+      return --Pointer;\r
     }\r
   } while (--Length != 0);\r
   return NULL;\r
@@ -237,7 +237,7 @@ InternalMemScanMem32 (
   @param  Length  The count of 64-bit value to scan. Must be non-zero.\r
   @param  Value   The value to search for in the target buffer.\r
 \r
-  @return The pointer to the first occurrence or NULL if not found.\r
+  @return The pointer to the first occurrence, or NULL if not found.\r
 \r
 **/\r
 CONST VOID *\r
@@ -253,7 +253,7 @@ InternalMemScanMem64 (
   Pointer = (CONST UINT64*)Buffer;\r
   do {\r
     if (*(Pointer++) == Value) {\r
-      return Pointer;\r
+      return --Pointer;\r
     }\r
   } while (--Length != 0);\r
   return NULL;\r