Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Toggle main menu visibility
Loading...
Searching...
No Matches
sapi_memory.h
Go to the documentation of this file.
1
18
#ifndef SAFEAPI_OS_MEMORY_H
19
#define SAFEAPI_OS_MEMORY_H
20
21
#include "
safeapi/utils/status/sapi_status.h
"
22
#include "
safeapi/utils/types/sapi_types.h
"
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif
27
29
SAFEAPI_DECLARE_STORAGE
(sapi_mem_pool_storage_t, 64U);
30
32
typedef
struct
sapi_mem_pool_impl_s *
sapi_mem_pool_handle_t
;
33
35
typedef
struct
sapi_mem_pool_config_s
36
{
37
size_t
block_size
;
38
size_t
block_count
;
39
}
sapi_mem_pool_config_t
;
40
53
sapi_status_t
sapi_mem_pool_create
(sapi_mem_pool_storage_t *storage,
54
const
sapi_mem_pool_config_t
*config,
55
sapi_mem_pool_handle_t
*out_handle);
56
67
sapi_status_t
sapi_mem_pool_acquire
(
sapi_mem_pool_handle_t
handle,
void
**out_block);
68
77
sapi_status_t
sapi_mem_pool_release
(
sapi_mem_pool_handle_t
handle,
void
*block);
78
88
sapi_status_t
sapi_mem_pool_stats
(
sapi_mem_pool_handle_t
handle,
89
size_t
*out_free_blocks,
90
size_t
*out_used_blocks);
91
92
/*
93
* The backend vtable (sapi_mem_pool_backend_t) and
94
* sapi_mem_pool_register_backend() live in
95
* safeapi_backend/memory/sapi_memory_backend.h, not here (ADR-021). This
96
* header is the consumer-facing surface only.
97
*/
98
99
#ifdef __cplusplus
100
}
101
#endif
102
103
#endif
/* SAFEAPI_OS_MEMORY_H */
104
/* MEMORY */
sapi_mem_pool_acquire
sapi_status_t sapi_mem_pool_acquire(sapi_mem_pool_handle_t handle, void **out_block)
Acquires one fixed-size block from the pool.
Definition
sapi_memory.c:77
sapi_mem_pool_create
sapi_status_t sapi_mem_pool_create(sapi_mem_pool_storage_t *storage, const sapi_mem_pool_config_t *config, sapi_mem_pool_handle_t *out_handle)
Reserves a fixed-size-block memory pool.
Definition
sapi_memory.c:44
sapi_mem_pool_handle_t
struct sapi_mem_pool_impl_s * sapi_mem_pool_handle_t
Opaque handle to a reserved pool, returned by sapi_mem_pool_create().
Definition
sapi_memory.h:32
sapi_mem_pool_release
sapi_status_t sapi_mem_pool_release(sapi_mem_pool_handle_t handle, void *block)
Returns a previously acquired block to its pool.
Definition
sapi_memory.c:95
sapi_mem_pool_stats
sapi_status_t sapi_mem_pool_stats(sapi_mem_pool_handle_t handle, size_t *out_free_blocks, size_t *out_used_blocks)
Reports current free/used block counts for diagnostics.
Definition
sapi_memory.c:112
sapi_status_t
sapi_status_t
Common result/status codes.
Definition
sapi_status.h:27
SAFEAPI_DECLARE_STORAGE
#define SAFEAPI_DECLARE_STORAGE(type_name, byte_size)
Declares an opaque, fixed-size, aligned storage type for a service's handle. The real internal layout...
Definition
sapi_types.h:69
sapi_status.h
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
sapi_types.h
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
sapi_mem_pool_config_t
Configuration for sapi_mem_pool_create().
Definition
sapi_memory.h:36
sapi_mem_pool_config_t::block_size
size_t block_size
Definition
sapi_memory.h:37
sapi_mem_pool_config_t::block_count
size_t block_count
Definition
sapi_memory.h:38
include
safeapi
oal
memory
sapi_memory.h
Generated by
1.18.0