From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::141; helo=mail-it1-x141.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it1-x141.google.com (mail-it1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7226C21A07A92 for ; Thu, 8 Nov 2018 03:13:58 -0800 (PST) Received: by mail-it1-x141.google.com with SMTP id e11so1029809itl.5 for ; Thu, 08 Nov 2018 03:13:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ez3v12V6/ZecyzDo1D7bFeThySUj/WOHVBNGwm+NHuY=; b=VAZBvDvKkx4+tcl3+DIVmkzcjYIHCQ5e3WI/C+sTB1hWj+VAJhQB7oVMRKWgakBXyp q/nw6OQeO25JupnZxGUJGXwyYSVc4ttG3WtxcHVvvIS6WtmdO/s1Q2+iqXcvLoeMFlXI cGy2nuvyEj/dk549e6+pEC8FUE03xeVmWtwu8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ez3v12V6/ZecyzDo1D7bFeThySUj/WOHVBNGwm+NHuY=; b=SJJFQ+wZaSs4GA8O9L1o8E1UbChQUj/TVQJf70Wzs0EAYTREPPtIvPj6FpM47RiSq7 NZg4EmgHg69zXjPvX/fS8nWyD59vavYjzKfh+THf1hbXytCrYjuYmMQfeTRv6pr2rVGV zluF85NjLHx1iAIWJNYkyCsrLsjjY+0UIVOiQBLR7KwNSBREAUVb2zc0zQhsLmTpE73x Bdv8n9lOSXMlqRovyDTSmFPA8hWNz5uqBDFrZXsWISk0dRIlY4IlPXrM9zwdrRs7QtUp jRp1CBAGQif6epBghtNPewttKjcIalqOhCIZxtTupTF1gwz0DBBisMGBhLv2Ya2PzkDd LDEg== X-Gm-Message-State: AGRZ1gKYZG+aG79bvYWq+UPWcEWdA6fBpyOYj/obSa5AzbP/PgFu5Ag/ dQlLGmeazuJ/xhEUR9f5p01lM9K0o54jxqjJZtqEEwdo X-Google-Smtp-Source: AJdET5fs/ro0nOUe3A/mQtehVaNJGL9al3t+fFEERMwCZm2px7wxPj9TgIx0U+lGUAs/kcJijqcqDJj9nItTHnh2Nf0= X-Received: by 2002:a24:7d8d:: with SMTP id b135-v6mr587714itc.121.1541675637506; Thu, 08 Nov 2018 03:13:57 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a6b:4f16:0:0:0:0:0 with HTTP; Thu, 8 Nov 2018 03:13:56 -0800 (PST) In-Reply-To: References: From: Ard Biesheuvel Date: Thu, 8 Nov 2018 12:13:56 +0100 Message-ID: To: Jeff Brasen , Leif Lindholm Cc: "edk2-devel@lists.01.org" Subject: Re: [PATCH 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 11:13:58 -0000 Content-Type: text/plain; charset="UTF-8" On 30 October 2018 at 22:30, Jeff Brasen 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 > --- > .../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 > > #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. I guess this is just boilerplate, but what on earth is 'a valid buffer of 0 size'? > 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 > + 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 > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel