]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
authorJeff Brasen <jbrasen@nvidia.com>
Thu, 8 Nov 2018 19:04:22 +0000 (03:04 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 29 Nov 2018 00:35:10 +0000 (08:35 +0800)
This function is exposed by the MemoryAllocationLib header.
An AllocateZeroPool() function has been added to fix modules depending on
this library and this function.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

index 0e75e23933393e1353d2d5401892b4fd85e77f2e..55e9249a5766d7df6c5843561b2ece0c9dbc7e4e 100644 (file)
@@ -16,6 +16,7 @@
 #include <PiPei.h>\r
 \r
 #include <Library/BaseLib.h>\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
 #include <Library/PrePiLib.h>\r
 #include <Library/DebugLib.h>\r
 \r
@@ -194,6 +195,37 @@ AllocatePool (
   }\r
 }\r
 \r
   }\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
 /**\r
   Frees a buffer that was previously allocated with one of the pool allocation functions in the\r
   Memory Allocation Library.\r