Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Memory allocation layer |
| 3 | * |
| 4 | * Copyright (C) 2006-2013, Brainspark B.V. |
| 5 | * |
| 6 | * This file is part of PolarSSL (http://www.polarssl.org) |
| 7 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
| 8 | * |
| 9 | * All rights reserved. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along |
| 22 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 24 | */ |
| 25 | |
| 26 | #include "polarssl/config.h" |
| 27 | |
| 28 | #if defined(POLARSSL_MEMORY_C) |
| 29 | |
| 30 | #include "polarssl/memory.h" |
| 31 | |
| 32 | #if !defined(POLARSSL_MEMORY_STDMALLOC) |
| 33 | static void *memory_malloc_uninit( size_t len ) |
| 34 | { |
| 35 | ((void) len); |
| 36 | return( NULL ); |
| 37 | } |
| 38 | |
| 39 | #define POLARSSL_MEMORY_STDMALLOC memory_malloc_uninit |
| 40 | #endif /* !POLARSSL_MEMORY_STDMALLOC */ |
| 41 | |
| 42 | #if !defined(POLARSSL_MEMORY_STDFREE) |
| 43 | static void memory_free_uninit( void *ptr ) |
| 44 | { |
| 45 | ((void) ptr); |
| 46 | } |
| 47 | |
| 48 | #define POLARSSL_MEMORY_STDFREE memory_free_uninit |
| 49 | #endif /* !POLARSSL_MEMORY_STDFREE */ |
| 50 | |
| 51 | void * (*polarssl_malloc)( size_t ) = POLARSSL_MEMORY_STDMALLOC; |
| 52 | void (*polarssl_free)( void * ) = POLARSSL_MEMORY_STDFREE; |
| 53 | |
| 54 | int memory_set_own( void * (*malloc_func)( size_t ), |
| 55 | void (*free_func)( void * ) ) |
| 56 | { |
| 57 | polarssl_malloc = malloc_func; |
| 58 | polarssl_free = free_func; |
| 59 | |
| 60 | return( 0 ); |
| 61 | } |
| 62 | |
| 63 | #endif /* POLARSSL_MEMORY_C */ |