memory_buffer_alloc.h
Go to the documentation of this file.
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBEDTLS_MEMORY_BUFFER_ALLOC_H
#define MBEDTLS_MEMORY_BUFFER_ALLOC_H
#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include <stddef.h>
#if !defined(MBEDTLS_MEMORY_ALIGN_MULTIPLE)
#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4
#endif
/* \} name SECTION: Module settings */
#define MBEDTLS_MEMORY_VERIFY_NONE 0
#define MBEDTLS_MEMORY_VERIFY_ALLOC (1 << 0)
#define MBEDTLS_MEMORY_VERIFY_FREE (1 << 1)
#define MBEDTLS_MEMORY_VERIFY_ALWAYS (MBEDTLS_MEMORY_VERIFY_ALLOC | MBEDTLS_MEMORY_VERIFY_FREE)
#ifdef __cplusplus
extern "C" {
#endif
void mbedtls_memory_buffer_alloc_init( unsigned char *buf, size_t len );
void mbedtls_memory_buffer_alloc_free( void );
void mbedtls_memory_buffer_set_verify( int verify );
#if defined(MBEDTLS_MEMORY_DEBUG)
void mbedtls_memory_buffer_alloc_status( void );
void mbedtls_memory_buffer_alloc_max_get( size_t *max_used, size_t *max_blocks );
void mbedtls_memory_buffer_alloc_max_reset( void );
void mbedtls_memory_buffer_alloc_cur_get( size_t *cur_used, size_t *cur_blocks );
#endif /* MBEDTLS_MEMORY_DEBUG */
int mbedtls_memory_buffer_alloc_verify( void );
#if defined(MBEDTLS_SELF_TEST)
int mbedtls_memory_buffer_alloc_self_test( int verbose );
#endif
#ifdef __cplusplus
}
#endif
#endif /* memory_buffer_alloc.h */
config.h
Configuration options (set of defines)
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...
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...
mbedtls_memory_buffer_alloc_free
void mbedtls_memory_buffer_alloc_free(void)
Free the mutex for thread-safety and clear remaining memory.