]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Pei/LzmaPeiMemory.c
Add LzmaCustomDecompressLib based on the LZMA SDK 4.65 which was
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / LzmaCustomDecompressLib / Pei / LzmaPeiMemory.c
1 /** @file
2 LZMA Memory Allocation for PEI
3
4 AllocatePool does not work for large blocks during PEI, so we must
5 use AllocatePages.
6
7 Copyright (c) 2006 - 2009, Intel Corporation<BR>
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #include <Uefi.h>
19 #include <Library/DebugLib.h>
20 #include <Library/MemoryAllocationLib.h>
21 #include "Sdk/C/Types.h"
22
23 STATIC
24 VOID *
25 SzAlloc(
26 void *p,
27 size_t size
28 )
29 {
30 void *np;
31 p = p;
32 if (size > EFI_PAGE_SIZE) {
33 np = AllocatePages(EFI_SIZE_TO_PAGES(size));
34 } else {
35 np = AllocatePool(size);
36 }
37 return np;
38 }
39
40 STATIC
41 VOID
42 SzFree(
43 void *p,
44 void *address
45 )
46 {
47 p = p;
48 if (address != NULL) {
49 FreePool(address);
50 }
51 }
52
53 ISzAlloc g_Alloc = { SzAlloc, SzFree };
54