]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c
CryptoPkg: Clean-up CRT Library Wrapper.
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / SysCall / BaseMemAllocation.c
CommitLineData
97f98500
HT
1/** @file\r
2 Base Memory Allocation Routines Wrapper for Crypto library over OpenSSL\r
3 during PEI & DXE phases.\r
4\r
fc9fa685 5Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
97f98500
HT
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
fc9fa685
QL
16#include <CrtLibSupport.h>\r
17#include <Library/MemoryAllocationLib.h>\r
97f98500
HT
18\r
19//\r
20// -- Memory-Allocation Routines --\r
21//\r
22\r
23/* Allocates memory blocks */\r
24void *malloc (size_t size)\r
25{\r
6b8ebcb8 26 return AllocatePool ((UINTN) size);\r
97f98500
HT
27}\r
28\r
29/* Reallocate memory blocks */\r
30void *realloc (void *ptr, size_t size)\r
31{\r
32 //\r
33 // BUG: hardcode OldSize == size! We have no any knowledge about\r
34 // memory size of original pointer ptr.\r
35 //\r
6b8ebcb8 36 return ReallocatePool ((UINTN) size, (UINTN) size, ptr);\r
97f98500
HT
37}\r
38\r
39/* De-allocates or frees a memory block */\r
40void free (void *ptr)\r
41{\r
211372d6
LE
42 //\r
43 // In Standard C, free() handles a null pointer argument transparently. This\r
44 // is not true of FreePool() below, so protect it.\r
45 //\r
46 if (ptr != NULL) {\r
47 FreePool (ptr);\r
48 }\r
97f98500 49}\r