|
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
|
Subsystem descriptor pattern for structured init/cleanup. More...
Go to the source code of this file.
Data Structures | |
| struct | SubsystemDescriptor |
| Describes one subsystem's lifecycle hooks. More... | |
Functions | |
| int | app_subsystems_init (struct App *app, const SubsystemDescriptor *table) |
Walk table forward calling init() until the sentinel {0}. | |
| void | app_subsystems_cleanup (struct App *app, const SubsystemDescriptor *table) |
Walk table in reverse, calling cleanup() for each entry. | |
Subsystem descriptor pattern for structured init/cleanup.
A SubsystemDescriptor is a {name, init, cleanup} triple. app_subsystems_init() walks the table forward, calling each init(); on failure it calls cleanup() in reverse for all previously-succeeded entries. app_subsystems_cleanup() walks the table in reverse, calling every non-NULL cleanup().
| void app_subsystems_cleanup | ( | struct App * | app, |
| const SubsystemDescriptor * | table | ||
| ) |
Walk table in reverse, calling cleanup() for each entry.
Skips entries whose cleanup function pointer is NULL. The table must be terminated by a {0} sentinel entry. Intended for the normal shutdown path after a successful init.
| int app_subsystems_init | ( | struct App * | app, |
| const SubsystemDescriptor * | table | ||
| ) |
Walk table forward calling init() until the sentinel {0}.
On the first failure at index N, cleanup() is called in reverse for entries [N-1 .. 0], then 0 is returned. The table must be terminated by a {0} sentinel entry.