Files
mruby-mruby/include
Yukihiro "Matz" Matsumoto 3cd2201b70 khash: add kh_init_data and kh_destroy_data functions
Add core data initialization functions that handle only the internal data
allocation/deallocation without managing the khash struct itself.

Changes:
- Add kh_init_data_##name() for initializing khash internal data
- Add kh_destroy_data_##name() for cleaning up khash internal data
- Refactor kh_init_##name##_size() to use kh_init_data internally
- Refactor kh_destroy_##name() to use kh_destroy_data internally
- Add corresponding kh_init_data() and kh_destroy_data() macros

Benefits:
- Eliminates code duplication between init/destroy and embed functions
- Provides clear separation: data functions handle internals, regular functions handle struct lifecycle
- Enables embedding khash in other structures (e.g., mruby-set's RSet)
- Centralizes complex initialization logic in single implementation

Architecture:
- kh_init_data/kh_destroy_data: core implementation with small table optimization
- kh_init_size/kh_destroy: convenience wrappers that add struct allocation
- Same functionality preserved, all tests pass

This prepares khash for mruby-set integration while improving code organization
and maintainability.

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-14 10:53:03 +09:00
..