diff options
author | Jeff Brasen <jbrasen@nvidia.com> | 2018-11-09 03:04:22 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2018-11-29 08:35:10 +0800 |
commit | 864cba9598a934ae3f7ae744b75d60e07dbd9fe9 (patch) | |
tree | 2568ce6fec5fbfa481d0819014df2c8962efbb5a /EmbeddedPkg/Library | |
parent | 591a44c02d92fcb9f1ec0950714d20c5da283d38 (diff) | |
download | edk2-864cba9598a934ae3f7ae744b75d60e07dbd9fe9.tar.gz edk2-864cba9598a934ae3f7ae744b75d60e07dbd9fe9.tar.bz2 edk2-864cba9598a934ae3f7ae744b75d60e07dbd9fe9.zip |
EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
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>
Diffstat (limited to 'EmbeddedPkg/Library')
-rw-r--r-- | EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c index 0e75e23933..55e9249a57 100644 --- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c @@ -16,6 +16,7 @@ #include <PiPei.h>
#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/PrePiLib.h>
#include <Library/DebugLib.h>
@@ -195,6 +196,37 @@ AllocatePool ( }
/**
+ Allocates and zeros a buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateZeroPool (
+ IN UINTN AllocationSize
+ )
+{
+ VOID *Buffer;
+
+ Buffer = AllocatePool (AllocationSize);
+ if (Buffer == NULL) {
+ return NULL;
+ }
+
+ ZeroMem (Buffer, AllocationSize);
+
+ return Buffer;
+}
+
+/**
Frees a buffer that was previously allocated with one of the pool allocation functions in the
Memory Allocation Library.
|