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