Complete Phase 1.2: Centralize layout definitions in tiny_layout_box.h

Changes:
- Updated ptr_conversion_box.h: Use TINY_HEADER_SIZE instead of hardcoded -1
- Updated tiny_front_hot_box.h: Use tiny_user_offset() for BASE->USER conversion
- Updated tiny_front_cold_box.h: Use tiny_user_offset() for BASE->USER conversion
- Added tiny_layout_box.h includes to both front box headers

Box theory: Layout parameters now isolated in dedicated Box component.
All offset arithmetic centralized - no scattered +1/-1 arithmetic.

Verified: Build succeeds (make clean && make shared -j8)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-12-03 17:18:31 +09:00
parent 4a2bf30790
commit f90e261c57
3 changed files with 13 additions and 4 deletions

View File

@ -25,6 +25,7 @@
#include "../hakmem_tiny_config.h"
#include "../tiny_region_id.h"
#include "../front/tiny_unified_cache.h" // For TinyUnifiedCache, unified_cache_refill
#include "tiny_layout_box.h" // For tiny_user_offset()
// ============================================================================
// Box 3: Tiny Cold Refill + Alloc
@ -76,7 +77,9 @@ static inline void* tiny_cold_refill_and_alloc(int class_idx) {
// NOTE: Header already written by unified_cache_refill()
// (Removed redundant tiny_region_id_write_header() - P2 fix)
#if HAKMEM_TINY_HEADER_CLASSIDX
return (void*)((char*)base + 1); // USER pointer
// Use centralized layout API for offset calculation
size_t user_offset = tiny_user_offset(class_idx);
return (void*)((char*)base + user_offset); // USER pointer
#else
return base;
#endif