PeiMemoryLib\r
UefiMemoryLib\r
\r
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2016, 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
IN UINT16 Value\r
)\r
{\r
- do {\r
- ((UINT16*)Buffer)[--Length] = Value;\r
- } while (Length != 0);\r
+ for (; Length != 0; Length--) {\r
+ ((UINT16*)Buffer)[Length - 1] = Value;\r
+ }\r
return Buffer;\r
}\r
\r
IN UINT32 Value\r
)\r
{\r
- do {\r
- ((UINT32*)Buffer)[--Length] = Value;\r
- } while (Length != 0);\r
+ for (; Length != 0; Length--) {\r
+ ((UINT32*)Buffer)[Length - 1] = Value;\r
+ }\r
return Buffer;\r
}\r
\r
IN UINT64 Value\r
)\r
{\r
- do {\r
- ((UINT64*)Buffer)[--Length] = Value;\r
- } while (Length != 0);\r
+ for (; Length != 0; Length--) {\r
+ ((UINT64*)Buffer)[Length - 1] = Value;\r
+ }\r
return Buffer;\r
}\r
\r
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
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
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
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
}\r
+\r
+/**\r
+ Checks whether the contents of a buffer are all zeros.\r
+\r
+ @param Buffer The pointer to the buffer to be checked.\r
+ @param Length The size of the buffer (in bytes) to be checked.\r
+\r
+ @retval TRUE Contents of the buffer are all zeros.\r
+ @retval FALSE Contents of the buffer are not all zeros.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+InternalMemIsZeroBuffer (\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Length\r
+ )\r
+{\r
+ CONST UINT8 *BufferData;\r
+ UINTN Index;\r
+\r
+ BufferData = Buffer;\r
+ for (Index = 0; Index < Length; Index++) {\r
+ if (BufferData[Index] != 0) {\r
+ return FALSE;\r
+ }\r
+ }\r
+ return TRUE;\r
+}\r