Commit Graph

24 Commits

Author SHA1 Message Date
anth64 baa75e897f refactor(module): centralize path parsing and add OS-specific separator
- Define STK_PATH_SEP macro to handle Windows and Unix path separators.
- Refactor extract_module_id to use STK_PATH_SEP.
- Simplify stk_module_load by delegating module ID extraction to extract_module_id.
2026-01-29 22:16:48 +01:00
anth64 c65b2eff6d fix: handle realloc to zero capacity
* Call stk_module_free_memory() when new_capacity is 0.
2026-01-28 00:45:39 +01:00
anth64 91ec40d5b1 fix: nullify module slots after unload
* Set all module slot fields (handle, init, shutdown, id) to NULL/empty
after unloading to prevent use-after-free and enable proper hole
detection during array defragmentation.
2026-01-28 00:18:29 +01:00
anth64 2823c8ab59 feat: add dynamic module array reallocation
* Implement stk_module_realloc_memory() to grow or shrink module arrays during hot-reload operations.
* All-or-nothing strategy with fallback to original pointers on partial realloc failure.
2026-01-28 00:04:34 +01:00
anth64 9491b070d2 refactor(WIP): replace event stubs with module identification logic
Replace the placeholder TODO logs in the polling loop with logic to
resolve filesystem events into specific module indices.

- Centralizing State: Refactored is_module_loaded to is_mod_loaded to
  check against the global stk_module_ids array, removing the need to
  pass local buffers and preparing for unified lifetime management.
- Standardizing Identity: Updated extract_module_id to use a
  consistent output buffer.
- Categorized Event Processing: Implemented a two-pass approach in
  stk_poll to count event types (LOAD, UNLOAD, RELOAD) and allocate
  tracking arrays, replacing the previous stubbed switch statement.
- Mapping Events to Indices: The poll loop now resolves filenames
  back to their specific loaded indices via is_mod_loaded to
  identify exactly which mod_id and index require action.
- Improved Flow Control: Introduced a finish_stk_poll label to
  ensure consistent cleanup and return values when no events are
  detected or processing is complete.
2026-01-27 07:54:51 +01:00
anth64 c558032ea0 feat: prevent configuration changes after initialization
* Introduced stk_initialized flag.
* Updated all configuration setters (stk_set_mod_dir, stk_set_tmp_dir_name, stk_set_module_init_fn, and stk_set_module_shutdown_fn) to silently return if the library is already initialized.
* Ensures internal state consistency by locking paths and function entry points once stk_init has been called.
2026-01-25 17:02:44 +01:00
anth64 472cb3b163 feat: make module paths and entry points configurable
* Added functions to set mod dir, temp dir name, and module init/shutdown function names.
* Replaced hardcoded string literals with configurable static buffers in module.c.
* Improved string safety by replacing sprintf with strncpy/strncat.
* Updated stk_init local path buffers to handle maximum combined path lengths.
2026-01-25 16:52:52 +01:00
anth64 42cf581125 fix: use union for ISO C compliant function pointer conversion 2026-01-19 07:57:40 +01:00
anth64 a3978644af refactor: centralize module identity logic and upgrade lookup
- Move extract_module_id and is_valid_module_file to module.c
- Update is_module_loaded to return module index instead of uint8_t
- Fix platform.c event checks to handle index-based return (>= 0)
- Centralize STK_MODULE_EXT definitions in stk.h
2026-01-18 22:01:54 +01:00
anth64 38469a358f Replace dynamic allocations with fixed-size buffers and add module extension filtering
- Use fixed STK_PATH_MAX and STK_MOD_ID_BUFFER throughout for predictable memory
- Filter by platform-specific extensions (.so/.dll/.dylib) with compile-time length
- Add RELOAD event detection and is_module_loaded() helper
- Maintain feature parity across all platforms
2026-01-17 19:52:42 +01:00
anth64 0649e287be extract_module_id is now not static 2025-12-20 08:22:41 -05:00
anth64 a30eeb7b1c extract_module_id non static -> static 2025-11-06 22:29:15 +01:00
anth64 8d4a506a91 extract_module_id(const char* path) static -> not static 2025-11-06 21:25:47 +01:00
anth64 0cf819fc73 stk module id static -> not static 2025-11-06 19:29:20 +01:00
anth64 3b993458d1 Add module ID tracking for hot-reloading
- Add stk_module_ids array to track module IDs by filename.
- extract_module_id() extracts module ID from it's filename.
- Enables tracking of file changes of already loaded modules.
2025-11-04 07:39:20 +01:00
anth64 35cc5afa9d Module discovery working for real this time
- Tested on Linux
- Allocate module memory before loading anything (seg fault fixed)
2025-11-02 19:41:56 +01:00
anth64 5c621c8367 Init/shutdown working
- stk_init/shutdown do what they are supposed to.
- buffer sizes moved to headers
2025-11-02 18:40:33 +01:00
anth64 7d7f02d1be use a constant for the mod dir buffer size 2025-11-02 12:44:10 +01:00
anth64 a66d9f9357 add mod dir 2025-11-02 12:30:26 +01:00
anth64 0e6664ec47 Implement Linux directory watching using inotify 2025-10-29 20:25:45 +01:00
anth64 bab9887fdb added functions to load/unload modules 2025-10-23 22:20:49 +02:00
anth64 df0954ba0d stk module count function, remove stk_ids since handles will be used as "ids" and typedef for stk module functions 2025-10-23 21:36:49 +02:00
anth64 4b6c3ffe2f instead of storing modules as a struct, switch to a more "ECS" style of handling modules 2025-10-09 07:55:41 +02:00
anth64 dfa190caea add minimal module struct 2025-10-08 21:58:22 +02:00