|
cwist
Modern C web framework with libttak runtime
|
Request-scoped arena and shared-payload helpers for session data. More...
#include <stddef.h>#include <stdint.h>

Go to the source code of this file.
Classes | |
| struct | session_rc_header |
| Reference-count header placed immediately before shared session payloads. More... | |
| struct | session_arena |
| Linear arena used for fast request-lifetime allocations. More... | |
| struct | session_manager |
| Top-level session allocator state owned by a request context. More... | |
Functions | |
| void | session_arena_init (struct session_arena *arena, uint8_t *buffer, size_t capacity) |
| Bind a caller-owned buffer to a session arena and reset its cursor. | |
| void * | session_arena_alloc (struct session_arena *arena, size_t size) |
| Allocate aligned storage from the request arena. | |
| void | session_arena_reset (struct session_arena *arena) |
| Reset the request arena so future allocations reuse the full buffer. | |
| void | session_rc_init (struct session_rc_header *header, void(*destructor)(void *)) |
| Initialize the metadata that tracks a shared session allocation. | |
| void * | session_shared_alloc (size_t payload_size, void(*destructor)(void *)) |
| Allocate a zeroed payload preceded by a reference-count header. | |
| void | session_shared_inc (void *payload) |
| Increment the reference count for a shared payload. | |
| void | session_shared_dec (void *payload) |
| Decrement the reference count and free the payload when it reaches zero. | |
| void | session_manager_init (struct session_manager *manager, uint8_t *buffer, size_t capacity) |
| Initialize a session manager around a caller-supplied arena buffer. | |
| void | session_manager_reset (struct session_manager *manager) |
| Reset all request-scoped allocations owned by the manager. | |
Request-scoped arena and shared-payload helpers for session data.
Definition in file session_manager.h.
| void * session_arena_alloc | ( | struct session_arena * | arena, |
| size_t | size | ||
| ) |
Allocate aligned storage from the request arena.
| arena | Arena to allocate from. |
| size | Requested payload size in bytes. |
Allocate aligned storage from the request arena.
Allocate from a session arena.
| arena | Arena that owns the backing storage. |
| size | Number of bytes requested before alignment. |
Definition at line 30 of file session_manager.c.
| void session_arena_init | ( | struct session_arena * | arena, |
| uint8_t * | buffer, | ||
| size_t | capacity | ||
| ) |
Bind a caller-owned buffer to a session arena and reset its cursor.
| arena | Arena to initialize. |
| buffer | Backing storage owned by the caller. |
| capacity | Size of buffer in bytes. |
Bind a caller-owned buffer to a session arena and reset its cursor.
Initialize a session arena.
| arena | Arena to initialize. |
| buffer | Backing storage to consume sequentially. |
| capacity | Total number of bytes available in buffer. |
Definition at line 17 of file session_manager.c.
Referenced by session_manager_init().
| void session_arena_reset | ( | struct session_arena * | arena | ) |
Reset the request arena so future allocations reuse the full buffer.
| arena | Arena to reset. |
Reset the request arena so future allocations reuse the full buffer.
Reset a session arena.
| arena | Arena to reset. |
Definition at line 46 of file session_manager.c.
Referenced by session_manager_reset().
| void session_manager_init | ( | struct session_manager * | manager, |
| uint8_t * | buffer, | ||
| size_t | capacity | ||
| ) |
Initialize a session manager around a caller-supplied arena buffer.
| manager | Session manager to initialize. |
| buffer | Buffer used for request-scoped arena allocations. |
| capacity | Size of buffer in bytes. |
Initialize a session manager around a caller-supplied arena buffer.
Initialize session manager.
| manager | Manager to initialize. |
| buffer | Backing arena storage. |
| capacity | Size of buffer in bytes. |
Definition at line 116 of file session_manager.c.
| void session_manager_reset | ( | struct session_manager * | manager | ) |
Reset all request-scoped allocations owned by the manager.
| manager | Session manager to reset. |
Reset session manager.
| manager | Manager whose arena should be rewound. |
Definition at line 125 of file session_manager.c.
| void session_rc_init | ( | struct session_rc_header * | header, |
| void(*)(void *) | destructor | ||
| ) |
Initialize the metadata that tracks a shared session allocation.
| header | Header to initialize. |
| destructor | Optional destructor invoked before the payload is freed. |
Initialize the metadata that tracks a shared session allocation.
Initialize reference-counted header.
| header | Header that precedes the payload. |
| destructor | Optional callback run just before the payload is freed. |
Definition at line 56 of file session_manager.c.
Referenced by session_shared_alloc().
Allocate a zeroed payload preceded by a reference-count header.
| payload_size | Number of bytes to expose to the caller. |
| destructor | Optional destructor for the payload. |
Allocate a zeroed payload preceded by a reference-count header.
Allocate shared session memory.
| payload_size | Number of bytes visible to callers. |
| destructor | Optional callback invoked before memory is released. |
Definition at line 68 of file session_manager.c.
Decrement the reference count and free the payload when it reaches zero.
| payload | Payload returned by session_shared_alloc(). |
Decrement the reference count and free the payload when it reaches zero.
Decrement reference count and free if zero.
| payload | Payload returned by session_shared_alloc(). |
Definition at line 96 of file session_manager.c.
Increment the reference count for a shared payload.
| payload | Payload returned by session_shared_alloc(). |
Increment reference count.
| payload | Payload returned by session_shared_alloc(). |
Definition at line 84 of file session_manager.c.