dipto181

memory.c

Sep 18th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  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 "config.h"
  27.  
  28. #if defined(POLARSSL_MEMORY_C)
  29.  
  30. #include "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. extern void *buffer_alloc_malloc( size_t len );
  55. extern void buffer_alloc_free( void *ptr );
  56. void * (*polarssl_malloc)( size_t ) = buffer_alloc_malloc;
  57. void (*polarssl_free)( void * ) = buffer_alloc_free;
  58.  
  59. int memory_set_own( void * (*malloc_func)( size_t ),
  60. void (*free_func)( void * ) )
  61. {
  62. polarssl_malloc = malloc_func;
  63. polarssl_free = free_func;
  64.  
  65. return( 0 );
  66. }
  67.  
  68. #endif /* POLARSSL_MEMORY_C */
  69.  
Add Comment
Please, Sign In to add comment