________________________________
From: Ard Biesheuvel <[email protected]>
Sent: Thursday, November 8, 2018 4:13 AM
To: Jeff Brasen; Leif Lindholm
Cc: [email protected]
Subject: Re: [edk2] [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added
AllocateZeroPool()
On 30 October 2018 at 22:30, Jeff Brasen <[email protected]> wrote:
> 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 <[email protected]>
> ---
> .../PrePiMemoryAllocationLib/MemoryAllocationLib.c | 32
> ++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git
> a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> index 0e75e23..f93f9cf 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.
I guess this is just boilerplate, but what on earth is 'a valid buffer
of 0 size'?
[JB] Copied this from the MemoryAllocationLib but allocate with create creates
a free-able buffer is created with a unique pointer but you can't read/write to
it (as it has no .
> 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 (NULL == Buffer) {
Please don't use Yoda speak
[JB] Will update, habit of mine from before compilers would generally report a
warning for assignments in if statements.
> + return NULL;
> + }
> +
> + SetMem (Buffer, AllocationSize, 0);
> +
> + return Buffer;
> +}
> +
> +/**
> Frees a buffer that was previously allocated with one of the pool
> allocation functions in the
> Memory Allocation Library.
>
> --
> 2.7.4
>
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.01.org/mailman/listinfo/edk2-devel
Thanks,
Jeff
Thanks,
Jeff
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may
contain
confidential information. Any unauthorized review, use, disclosure or
distribution
is prohibited. If you are not the intended recipient, please contact the
sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel