From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=216.228.121.64; helo=hqemgate15.nvidia.com; envelope-from=jbrasen@nvidia.com; receiver=edk2-devel@lists.01.org Received: from hqemgate15.nvidia.com (hqemgate15.nvidia.com [216.228.121.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DDDB821B02822 for ; Thu, 8 Nov 2018 09:09:36 -0800 (PST) Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 08 Nov 2018 09:09:33 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 08 Nov 2018 09:09:36 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 08 Nov 2018 09:09:36 -0800 Received: from HQMAIL112.nvidia.com (172.18.146.18) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 8 Nov 2018 17:09:35 +0000 Received: from HQMAIL108.nvidia.com (172.18.146.13) by HQMAIL112.nvidia.com (172.18.146.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 8 Nov 2018 17:09:35 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL108.nvidia.com (172.18.146.13) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Thu, 8 Nov 2018 17:09:35 +0000 Received: from jbrasen-ux.nvidia.com (Not Verified[10.28.48.113]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 08 Nov 2018 09:09:35 -0800 From: Jeff Brasen To: CC: , , Jeff Brasen Date: Thu, 8 Nov 2018 10:09:25 -0700 Message-ID: <5e0b0bba39ff2234a7005612a8d718719a952145.1541696528.git.jbrasen@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-NVConfidentiality: public MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1541696973; bh=uU+K4L0NFFSvWSbYt0nR0J807AtaHdOx32+D16ptqTA=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=jjwM280ccweaB7Q4+jde95sSLsyjBFGny92LFLDPuoSPXMioUkHtQgO0WIVnL1YiL ojvu1dvSmKCrulFCbJnyqmnEmt8Ixu0b01Vrn+4/sZqAuwSUuW4wNwR64+aCFxBz+s OdjpsKfecFxmg90TcwtK/3YuPns8vwyRuSFQDHswcTg1UNFU9OIW10Sfh7nixOnUjC raK1q8OhNUC4w005HtedWmfh6/HTFzRd7aMS0/PhhmKRVqPu9txzXqwzusAydQlrZJ TQ4LmpIbH6Sw5LKcI8xv9UmERgP6Yr8S6uC9zchMWholDagtF84uTLUw0JyzaURadf w6ygjDOKcnnvQ== Subject: [PATCH v2 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Nov 2018 17:09:37 -0000 Content-Type: text/plain 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 --- .../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..c39d140 100644 --- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -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; + } + + 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