Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
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
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
29SAFEAPI_DECLARE_STORAGE(sapi_mem_pool_storage_t, 64U);
30
32typedef struct sapi_mem_pool_impl_s *sapi_mem_pool_handle_t;
33
35typedef struct sapi_mem_pool_config_s
36{
37 size_t block_size;
38 size_t block_count;
40
53sapi_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
68
78
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_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_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
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_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_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.
sapi_status_t
Common result/status codes.
Definition sapi_status.h:27
#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
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
Configuration for sapi_mem_pool_create().
Definition sapi_memory.h:36