mbed TLS v2.16.1
memory_buffer_alloc.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8  * SPDX-License-Identifier: GPL-2.0
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  *
24  * This file is part of mbed TLS (https://tls.mbed.org)
25  */
26 #ifndef MBEDTLS_MEMORY_BUFFER_ALLOC_H
27 #define MBEDTLS_MEMORY_BUFFER_ALLOC_H
28 
29 #if !defined(MBEDTLS_CONFIG_FILE)
30 #include "config.h"
31 #else
32 #include MBEDTLS_CONFIG_FILE
33 #endif
34 
35 #include <stddef.h>
36 
45 #if !defined(MBEDTLS_MEMORY_ALIGN_MULTIPLE)
46 #define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4
47 #endif
48 
49 /* \} name SECTION: Module settings */
50 
51 #define MBEDTLS_MEMORY_VERIFY_NONE 0
52 #define MBEDTLS_MEMORY_VERIFY_ALLOC (1 << 0)
53 #define MBEDTLS_MEMORY_VERIFY_FREE (1 << 1)
54 #define MBEDTLS_MEMORY_VERIFY_ALWAYS (MBEDTLS_MEMORY_VERIFY_ALLOC | MBEDTLS_MEMORY_VERIFY_FREE)
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
75 void mbedtls_memory_buffer_alloc_init( unsigned char *buf, size_t len );
76 
81 
90 void mbedtls_memory_buffer_set_verify( int verify );
91 
92 #if defined(MBEDTLS_MEMORY_DEBUG)
93 
99 void mbedtls_memory_buffer_alloc_status( void );
100 
109 void mbedtls_memory_buffer_alloc_max_get( size_t *max_used, size_t *max_blocks );
110 
114 void mbedtls_memory_buffer_alloc_max_reset( void );
115 
124 void mbedtls_memory_buffer_alloc_cur_get( size_t *cur_used, size_t *cur_blocks );
125 #endif /* MBEDTLS_MEMORY_DEBUG */
126 
139 
140 #if defined(MBEDTLS_SELF_TEST)
141 
146 int mbedtls_memory_buffer_alloc_self_test( int verbose );
147 #endif
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /* memory_buffer_alloc.h */
int mbedtls_memory_buffer_alloc_self_test(int verbose)
Checkup routine.
int mbedtls_memory_buffer_alloc_verify(void)
Verifies that all headers in the memory buffer are correct and contain sane values. Helps debug buffer-overflow errors.
Configuration options (set of defines)
void mbedtls_memory_buffer_alloc_init(unsigned char *buf, size_t len)
Initialize use of stack-based memory allocator. The stack-based allocator does memory management insi...
void mbedtls_memory_buffer_alloc_free(void)
Free the mutex for thread-safety and clear remaining memory.
void mbedtls_memory_buffer_set_verify(int verify)
Determine when the allocator should automatically verify the state of the entire chain of headers / m...