]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
EmbeddedPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmbeddedPkg / Library / PrePiMemoryAllocationLib / MemoryAllocationLib.c
index c22682a9183d92a9bb90c87b0a9eba63c160012e..7ce71c27cb8ccb8ce9c3c5257b22e3307587b24e 100644 (file)
@@ -2,20 +2,15 @@
   Implementation of the 6 PEI Ffs (FV) APIs in library form.\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-  \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
-  http://opensource.org/licenses/bsd-license.php\r
 \r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 #include <PiPei.h>\r
 \r
 #include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
 #include <Library/PrePiLib.h>\r
 #include <Library/DebugLib.h>\r
 \r
@@ -180,7 +175,7 @@ AllocatePool (
 \r
   Hob = GetHobList ();\r
 \r
-  \r
+\r
   //\r
   // Verify that there is sufficient memory to satisfy the allocation\r
   //\r
@@ -194,6 +189,37 @@ AllocatePool (
   }\r
 }\r
 \r
+/**\r
+  Allocates and zeros a buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateZeroPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  VOID *Buffer;\r
+\r
+  Buffer = AllocatePool (AllocationSize);\r
+  if (Buffer == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  ZeroMem (Buffer, AllocationSize);\r
+\r
+  return Buffer;\r
+}\r
+\r
 /**\r
   Frees a buffer that was previously allocated with one of the pool allocation functions in the\r
   Memory Allocation Library.\r