MemoryAllocationLibPosix.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /** @file
  2. Instance of Memory Allocation Library based on POSIX APIs
  3. Uses POSIX APIs malloc() and free() to allocate and free memory.
  4. Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <Uefi.h>
  10. #include <Library/MemoryAllocationLib.h>
  11. #include <Library/DebugLib.h>
  12. ///
  13. /// Signature for PAGE_HEAD structure
  14. /// Used to verify that buffer being freed was allocated by this library.
  15. ///
  16. #define PAGE_HEAD_PRIVATE_SIGNATURE SIGNATURE_32 ('P', 'H', 'D', 'R')
  17. ///
  18. /// Structure placed immediately before an aligned allocation to store the
  19. /// information required to free the entire buffer allocated to support then
  20. /// aligned allocation.
  21. ///
  22. typedef struct {
  23. UINT32 Signature;
  24. VOID *AllocatedBufffer;
  25. UINTN TotalPages;
  26. VOID *AlignedBuffer;
  27. UINTN AlignedPages;
  28. } PAGE_HEAD;
  29. /**
  30. Allocates one or more 4KB pages of type EfiBootServicesData.
  31. Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
  32. allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
  33. is returned. If there is not enough memory remaining to satisfy the request, then NULL is
  34. returned.
  35. @param Pages The number of 4 KB pages to allocate.
  36. @return A pointer to the allocated buffer or NULL if allocation fails.
  37. **/
  38. VOID *
  39. EFIAPI
  40. AllocatePages (
  41. IN UINTN Pages
  42. )
  43. {
  44. return AllocateAlignedPages (Pages, SIZE_4KB);
  45. }
  46. /**
  47. Allocates one or more 4KB pages of type EfiRuntimeServicesData.
  48. Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
  49. allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
  50. is returned. If there is not enough memory remaining to satisfy the request, then NULL is
  51. returned.
  52. @param Pages The number of 4 KB pages to allocate.
  53. @return A pointer to the allocated buffer or NULL if allocation fails.
  54. **/
  55. VOID *
  56. EFIAPI
  57. AllocateRuntimePages (
  58. IN UINTN Pages
  59. )
  60. {
  61. return AllocatePages (Pages);
  62. }
  63. /**
  64. Allocates one or more 4KB pages of type EfiReservedMemoryType.
  65. Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
  66. allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
  67. is returned. If there is not enough memory remaining to satisfy the request, then NULL is
  68. returned.
  69. @param Pages The number of 4 KB pages to allocate.
  70. @return A pointer to the allocated buffer or NULL if allocation fails.
  71. **/
  72. VOID *
  73. EFIAPI
  74. AllocateReservedPages (
  75. IN UINTN Pages
  76. )
  77. {
  78. return AllocatePages (Pages);
  79. }
  80. /**
  81. Frees one or more 4KB pages that were previously allocated with one of the page allocation
  82. functions in the Memory Allocation Library.
  83. Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
  84. must have been allocated on a previous call to the page allocation services of the Memory
  85. Allocation Library. If it is not possible to free allocated pages, then this function will
  86. perform no actions.
  87. If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
  88. then ASSERT().
  89. If Pages is zero, then ASSERT().
  90. @param Buffer The pointer to the buffer of pages to free.
  91. @param Pages The number of 4 KB pages to free.
  92. **/
  93. VOID
  94. EFIAPI
  95. FreePages (
  96. IN VOID *Buffer,
  97. IN UINTN Pages
  98. )
  99. {
  100. FreeAlignedPages (Buffer, Pages);
  101. }
  102. /**
  103. Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
  104. Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
  105. alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
  106. returned. If there is not enough memory at the specified alignment remaining to satisfy the
  107. request, then NULL is returned.
  108. If Alignment is not a power of two and Alignment is not zero, then ASSERT().
  109. If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
  110. @param Pages The number of 4 KB pages to allocate.
  111. @param Alignment The requested alignment of the allocation. Must be a power of two.
  112. If Alignment is zero, then byte alignment is used.
  113. @return A pointer to the allocated buffer or NULL if allocation fails.
  114. **/VOID *
  115. EFIAPI
  116. AllocateAlignedPages (
  117. IN UINTN Pages,
  118. IN UINTN Alignment
  119. )
  120. {
  121. PAGE_HEAD PageHead;
  122. PAGE_HEAD *PageHeadPtr;
  123. UINTN AlignmentMask;
  124. ASSERT ((Alignment & (Alignment - 1)) == 0);
  125. if (Alignment < SIZE_4KB) {
  126. Alignment = SIZE_4KB;
  127. }
  128. AlignmentMask = Alignment - 1;
  129. //
  130. // We need reserve Alignment pages for PAGE_HEAD, as meta data.
  131. //
  132. PageHead.Signature = PAGE_HEAD_PRIVATE_SIGNATURE;
  133. PageHead.TotalPages = Pages + EFI_SIZE_TO_PAGES (Alignment) * 2;
  134. PageHead.AlignedPages = Pages;
  135. PageHead.AllocatedBufffer = malloc (EFI_PAGES_TO_SIZE (PageHead.TotalPages));
  136. if (PageHead.AllocatedBufffer == NULL) {
  137. return NULL;
  138. }
  139. PageHead.AlignedBuffer = (VOID *)(((UINTN)PageHead.AllocatedBufffer + AlignmentMask) & ~AlignmentMask);
  140. if ((UINTN)PageHead.AlignedBuffer - (UINTN)PageHead.AllocatedBufffer < sizeof (PAGE_HEAD)) {
  141. PageHead.AlignedBuffer = (VOID *)((UINTN)PageHead.AlignedBuffer + Alignment);
  142. }
  143. PageHeadPtr = (VOID *)((UINTN)PageHead.AlignedBuffer - sizeof (PAGE_HEAD));
  144. memcpy (PageHeadPtr, &PageHead, sizeof (PAGE_HEAD));
  145. return PageHead.AlignedBuffer;
  146. }
  147. /**
  148. Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
  149. Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
  150. alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
  151. returned. If there is not enough memory at the specified alignment remaining to satisfy the
  152. request, then NULL is returned.
  153. If Alignment is not a power of two and Alignment is not zero, then ASSERT().
  154. If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
  155. @param Pages The number of 4 KB pages to allocate.
  156. @param Alignment The requested alignment of the allocation. Must be a power of two.
  157. If Alignment is zero, then byte alignment is used.
  158. @return A pointer to the allocated buffer or NULL if allocation fails.
  159. **/
  160. VOID *
  161. EFIAPI
  162. AllocateAlignedRuntimePages (
  163. IN UINTN Pages,
  164. IN UINTN Alignment
  165. )
  166. {
  167. return AllocateAlignedPages (Pages, Alignment);
  168. }
  169. /**
  170. Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
  171. Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
  172. alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
  173. returned. If there is not enough memory at the specified alignment remaining to satisfy the
  174. request, then NULL is returned.
  175. If Alignment is not a power of two and Alignment is not zero, then ASSERT().
  176. If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
  177. @param Pages The number of 4 KB pages to allocate.
  178. @param Alignment The requested alignment of the allocation. Must be a power of two.
  179. If Alignment is zero, then byte alignment is used.
  180. @return A pointer to the allocated buffer or NULL if allocation fails.
  181. **/
  182. VOID *
  183. EFIAPI
  184. AllocateAlignedReservedPages (
  185. IN UINTN Pages,
  186. IN UINTN Alignment
  187. )
  188. {
  189. return AllocateAlignedPages (Pages, Alignment);
  190. }
  191. /**
  192. Frees one or more 4KB pages that were previously allocated with one of the aligned page
  193. allocation functions in the Memory Allocation Library.
  194. Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
  195. must have been allocated on a previous call to the aligned page allocation services of the Memory
  196. Allocation Library. If it is not possible to free allocated pages, then this function will
  197. perform no actions.
  198. If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
  199. Library, then ASSERT().
  200. If Pages is zero, then ASSERT().
  201. @param Buffer The pointer to the buffer of pages to free.
  202. @param Pages The number of 4 KB pages to free.
  203. **/
  204. VOID
  205. EFIAPI
  206. FreeAlignedPages (
  207. IN VOID *Buffer,
  208. IN UINTN Pages
  209. )
  210. {
  211. PAGE_HEAD *PageHeadPtr;
  212. //
  213. // NOTE: Partial free is not supported. Just keep it.
  214. //
  215. PageHeadPtr = (VOID *)((UINTN)Buffer - sizeof (PAGE_HEAD));
  216. if (PageHeadPtr->Signature != PAGE_HEAD_PRIVATE_SIGNATURE) {
  217. return;
  218. }
  219. if (PageHeadPtr->AlignedPages != Pages) {
  220. return;
  221. }
  222. PageHeadPtr->Signature = 0;
  223. free (PageHeadPtr->AllocatedBufffer);
  224. }
  225. /**
  226. Allocates a buffer of type EfiBootServicesData.
  227. Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
  228. pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
  229. returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
  230. @param AllocationSize The number of bytes to allocate.
  231. @return A pointer to the allocated buffer or NULL if allocation fails.
  232. **/VOID *
  233. EFIAPI
  234. AllocatePool (
  235. IN UINTN AllocationSize
  236. )
  237. {
  238. return malloc (AllocationSize);
  239. }
  240. /**
  241. Allocates a buffer of type EfiRuntimeServicesData.
  242. Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
  243. a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
  244. returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
  245. @param AllocationSize The number of bytes to allocate.
  246. @return A pointer to the allocated buffer or NULL if allocation fails.
  247. **/
  248. VOID *
  249. EFIAPI
  250. AllocateRuntimePool (
  251. IN UINTN AllocationSize
  252. )
  253. {
  254. return AllocatePool (AllocationSize);
  255. }
  256. /**
  257. Allocates a buffer of type EfiReservedMemoryType.
  258. Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
  259. a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
  260. returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
  261. @param AllocationSize The number of bytes to allocate.
  262. @return A pointer to the allocated buffer or NULL if allocation fails.
  263. **/
  264. VOID *
  265. EFIAPI
  266. AllocateReservedPool (
  267. IN UINTN AllocationSize
  268. )
  269. {
  270. return AllocatePool (AllocationSize);
  271. }
  272. /**
  273. Allocates and zeros a buffer of type EfiBootServicesData.
  274. Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
  275. buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
  276. valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
  277. request, then NULL is returned.
  278. @param AllocationSize The number of bytes to allocate and zero.
  279. @return A pointer to the allocated buffer or NULL if allocation fails.
  280. **/
  281. VOID *
  282. EFIAPI
  283. AllocateZeroPool (
  284. IN UINTN AllocationSize
  285. )
  286. {
  287. VOID *Buffer;
  288. Buffer = malloc (AllocationSize);
  289. if (Buffer == NULL) {
  290. return NULL;
  291. }
  292. memset (Buffer, 0, AllocationSize);
  293. return Buffer;
  294. }
  295. /**
  296. Allocates and zeros a buffer of type EfiRuntimeServicesData.
  297. Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
  298. buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
  299. valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
  300. request, then NULL is returned.
  301. @param AllocationSize The number of bytes to allocate and zero.
  302. @return A pointer to the allocated buffer or NULL if allocation fails.
  303. **/
  304. VOID *
  305. EFIAPI
  306. AllocateRuntimeZeroPool (
  307. IN UINTN AllocationSize
  308. )
  309. {
  310. return AllocateZeroPool (AllocationSize);
  311. }
  312. /**
  313. Allocates and zeros a buffer of type EfiReservedMemoryType.
  314. Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
  315. buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
  316. valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
  317. request, then NULL is returned.
  318. @param AllocationSize The number of bytes to allocate and zero.
  319. @return A pointer to the allocated buffer or NULL if allocation fails.
  320. **/
  321. VOID *
  322. EFIAPI
  323. AllocateReservedZeroPool (
  324. IN UINTN AllocationSize
  325. )
  326. {
  327. return AllocateZeroPool (AllocationSize);
  328. }
  329. /**
  330. Copies a buffer to an allocated buffer of type EfiBootServicesData.
  331. Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
  332. AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
  333. allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
  334. is not enough memory remaining to satisfy the request, then NULL is returned.
  335. If Buffer is NULL, then ASSERT().
  336. If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
  337. @param AllocationSize The number of bytes to allocate and zero.
  338. @param Buffer The buffer to copy to the allocated buffer.
  339. @return A pointer to the allocated buffer or NULL if allocation fails.
  340. **/
  341. VOID *
  342. EFIAPI
  343. AllocateCopyPool (
  344. IN UINTN AllocationSize,
  345. IN CONST VOID *Buffer
  346. )
  347. {
  348. VOID *Memory;
  349. Memory = malloc (AllocationSize);
  350. if (Memory == NULL) {
  351. return NULL;
  352. }
  353. memcpy (Memory, Buffer, AllocationSize);
  354. return Memory;
  355. }
  356. /**
  357. Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
  358. Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
  359. AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
  360. allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
  361. is not enough memory remaining to satisfy the request, then NULL is returned.
  362. If Buffer is NULL, then ASSERT().
  363. If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
  364. @param AllocationSize The number of bytes to allocate and zero.
  365. @param Buffer The buffer to copy to the allocated buffer.
  366. @return A pointer to the allocated buffer or NULL if allocation fails.
  367. **/
  368. VOID *
  369. EFIAPI
  370. AllocateRuntimeCopyPool (
  371. IN UINTN AllocationSize,
  372. IN CONST VOID *Buffer
  373. )
  374. {
  375. return AllocateCopyPool (AllocationSize, Buffer);
  376. }
  377. /**
  378. Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
  379. Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
  380. AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
  381. allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
  382. is not enough memory remaining to satisfy the request, then NULL is returned.
  383. If Buffer is NULL, then ASSERT().
  384. If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
  385. @param AllocationSize The number of bytes to allocate and zero.
  386. @param Buffer The buffer to copy to the allocated buffer.
  387. @return A pointer to the allocated buffer or NULL if allocation fails.
  388. **/
  389. VOID *
  390. EFIAPI
  391. AllocateReservedCopyPool (
  392. IN UINTN AllocationSize,
  393. IN CONST VOID *Buffer
  394. )
  395. {
  396. return AllocateCopyPool (AllocationSize, Buffer);
  397. }
  398. /**
  399. Reallocates a buffer of type EfiBootServicesData.
  400. Allocates and zeros the number bytes specified by NewSize from memory of type
  401. EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
  402. NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
  403. OldBuffer is freed. A pointer to the newly allocated buffer is returned.
  404. If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
  405. enough memory remaining to satisfy the request, then NULL is returned.
  406. If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
  407. is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
  408. @param OldSize The size, in bytes, of OldBuffer.
  409. @param NewSize The size, in bytes, of the buffer to reallocate.
  410. @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
  411. parameter that may be NULL.
  412. @return A pointer to the allocated buffer or NULL if allocation fails.
  413. **/
  414. VOID *
  415. EFIAPI
  416. ReallocatePool (
  417. IN UINTN OldSize,
  418. IN UINTN NewSize,
  419. IN VOID *OldBuffer OPTIONAL
  420. )
  421. {
  422. VOID *NewBuffer;
  423. NewBuffer = malloc (NewSize);
  424. if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
  425. memcpy (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
  426. }
  427. if (OldBuffer != NULL) {
  428. FreePool (OldBuffer);
  429. }
  430. return NewBuffer;
  431. }
  432. /**
  433. Reallocates a buffer of type EfiRuntimeServicesData.
  434. Allocates and zeros the number bytes specified by NewSize from memory of type
  435. EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
  436. NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
  437. OldBuffer is freed. A pointer to the newly allocated buffer is returned.
  438. If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
  439. enough memory remaining to satisfy the request, then NULL is returned.
  440. If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
  441. is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
  442. @param OldSize The size, in bytes, of OldBuffer.
  443. @param NewSize The size, in bytes, of the buffer to reallocate.
  444. @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
  445. parameter that may be NULL.
  446. @return A pointer to the allocated buffer or NULL if allocation fails.
  447. **/
  448. VOID *
  449. EFIAPI
  450. ReallocateRuntimePool (
  451. IN UINTN OldSize,
  452. IN UINTN NewSize,
  453. IN VOID *OldBuffer OPTIONAL
  454. )
  455. {
  456. return ReallocatePool (OldSize, NewSize, OldBuffer);
  457. }
  458. /**
  459. Reallocates a buffer of type EfiReservedMemoryType.
  460. Allocates and zeros the number bytes specified by NewSize from memory of type
  461. EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
  462. NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
  463. OldBuffer is freed. A pointer to the newly allocated buffer is returned.
  464. If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
  465. enough memory remaining to satisfy the request, then NULL is returned.
  466. If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
  467. is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
  468. @param OldSize The size, in bytes, of OldBuffer.
  469. @param NewSize The size, in bytes, of the buffer to reallocate.
  470. @param OldBuffer The buffer to copy to the allocated buffer. This is an optional
  471. parameter that may be NULL.
  472. @return A pointer to the allocated buffer or NULL if allocation fails.
  473. **/
  474. VOID *
  475. EFIAPI
  476. ReallocateReservedPool (
  477. IN UINTN OldSize,
  478. IN UINTN NewSize,
  479. IN VOID *OldBuffer OPTIONAL
  480. )
  481. {
  482. return ReallocatePool (OldSize, NewSize, OldBuffer);
  483. }
  484. /**
  485. Frees a buffer that was previously allocated with one of the pool allocation functions in the
  486. Memory Allocation Library.
  487. Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
  488. pool allocation services of the Memory Allocation Library. If it is not possible to free pool
  489. resources, then this function will perform no actions.
  490. If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
  491. then ASSERT().
  492. @param Buffer The pointer to the buffer to free.
  493. **/
  494. VOID
  495. EFIAPI
  496. FreePool (
  497. IN VOID *Buffer
  498. )
  499. {
  500. free (Buffer);
  501. }