Mbed TLS v2.28.8
memory_buffer_alloc.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9  */
10 #ifndef MBEDTLS_MEMORY_BUFFER_ALLOC_H
11 #define MBEDTLS_MEMORY_BUFFER_ALLOC_H
12 
13 #if !defined(MBEDTLS_CONFIG_FILE)
14 #include "mbedtls/config.h"
15 #else
16 #include MBEDTLS_CONFIG_FILE
17 #endif
18 
19 #include <stddef.h>
20 
29 #if !defined(MBEDTLS_MEMORY_ALIGN_MULTIPLE)
30 #define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4
31 #endif
32 
35 #define MBEDTLS_MEMORY_VERIFY_NONE 0
36 #define MBEDTLS_MEMORY_VERIFY_ALLOC (1 << 0)
37 #define MBEDTLS_MEMORY_VERIFY_FREE (1 << 1)
38 #define MBEDTLS_MEMORY_VERIFY_ALWAYS (MBEDTLS_MEMORY_VERIFY_ALLOC | \
39  MBEDTLS_MEMORY_VERIFY_FREE)
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
60 void mbedtls_memory_buffer_alloc_init(unsigned char *buf, size_t len);
61 
66 
75 void mbedtls_memory_buffer_set_verify(int verify);
76 
77 #if defined(MBEDTLS_MEMORY_DEBUG)
78 
84 void mbedtls_memory_buffer_alloc_status(void);
85 
94 void mbedtls_memory_buffer_alloc_max_get(size_t *max_used, size_t *max_blocks);
95 
99 void mbedtls_memory_buffer_alloc_max_reset(void);
100 
109 void mbedtls_memory_buffer_alloc_cur_get(size_t *cur_used, size_t *cur_blocks);
110 #endif /* MBEDTLS_MEMORY_DEBUG */
111 
124 
125 #if defined(MBEDTLS_SELF_TEST)
126 
132 #endif
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif /* memory_buffer_alloc.h */
mbedtls_memory_buffer_alloc_verify
int mbedtls_memory_buffer_alloc_verify(void)
Verifies that all headers in the memory buffer are correct and contain sane values....
mbedtls_memory_buffer_set_verify
void mbedtls_memory_buffer_set_verify(int verify)
Determine when the allocator should automatically verify the state of the entire chain of headers / m...
config.h
Configuration options (set of defines)
mbedtls_memory_buffer_alloc_free
void mbedtls_memory_buffer_alloc_free(void)
Free the mutex for thread-safety and clear remaining memory.
mbedtls_memory_buffer_alloc_self_test
int mbedtls_memory_buffer_alloc_self_test(int verbose)
Checkup routine.
mbedtls_memory_buffer_alloc_init
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...