boot1.efi should also provide Calloc

boot1.efi does provide Malloc and Free, we also need Calloc.
This commit is contained in:
Toomas Soome 2019-05-29 07:32:43 +00:00
parent 51e5c6b89e
commit f28f385b9c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348353

View File

@ -54,10 +54,11 @@ static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL;
static EFI_GUID ConsoleControlGUID = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
/*
* Provide Malloc / Free backed by EFIs AllocatePool / FreePool which ensures
* Provide Malloc / Free / Calloc backed by EFIs AllocatePool / FreePool which ensures
* memory is correctly aligned avoiding EFI_INVALID_PARAMETER returns from
* EFI methods.
*/
void *
Malloc(size_t len, const char *file __unused, int line __unused)
{
@ -76,6 +77,19 @@ Free(void *buf, const char *file __unused, int line __unused)
(void)BS->FreePool(buf);
}
void *
Calloc(size_t n1, size_t n2, const char *file, int line)
{
size_t bytes;
void *res;
bytes = n1 * n2;
if ((res = Malloc(bytes, file, line)) != NULL)
bzero(res, bytes);
return (res);
}
/*
* load_loader attempts to load the loader image data.
*