TianoCore EDK2 master
Loading...
Searching...
No Matches
WinMemoryAllocationLib.c
1/*++ @file
2
3 Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#include <Base.h>
12
13#include <stdlib.h>
14
27VOID *
28EFIAPI
30 IN UINTN AllocationSize
31 )
32{
33 return (VOID *)malloc (AllocationSize);
34}
35
49VOID *
50EFIAPI
52 IN UINTN AllocationSize
53 )
54{
55 VOID *Buffer;
56
57 Buffer = AllocatePool (AllocationSize);
58 if (Buffer == NULL) {
59 return NULL;
60 }
61
62 ZeroMem (Buffer, AllocationSize);
63
64 return Buffer;
65}
66
88VOID *
89EFIAPI
91 IN UINTN OldSize,
92 IN UINTN NewSize,
93 IN VOID *OldBuffer OPTIONAL
94 )
95{
96 VOID *NewBuffer;
97
98 NewBuffer = AllocatePool (NewSize);
99 if (NewBuffer == NULL) {
100 return NULL;
101 }
102
103 if (OldBuffer != NULL) {
104 if (OldSize > 0) {
105 CopyMem (NewBuffer, OldBuffer, OldSize);
106 }
107
108 FreePool (OldBuffer);
109 }
110
111 return NewBuffer;
112}
113
131VOID *
132EFIAPI
134 IN UINTN AllocationSize,
135 IN CONST VOID *Buffer
136 )
137{
138 VOID *Memory;
139
140 Memory = AllocatePool (AllocationSize);
141 if (Memory != NULL) {
142 Memory = CopyMem (Memory, Buffer, AllocationSize);
143 }
144
145 return Memory;
146}
147
162VOID
163EFIAPI
164FreePool (
165 IN VOID *Buffer
166 )
167{
168 free ((void *)Buffer);
169}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)