// ss_slab_reset_box.h // Box: Reset TinySlabMeta for reuse (C7 diagnostics-friendly) #pragma once #include "ss_slab_meta_box.h" #include "../superslab/superslab_inline.h" #include static inline void ss_slab_reset_meta_for_tiny(SuperSlab* ss, int slab_idx, int class_idx) { if (!ss) return; if (slab_idx < 0 || slab_idx >= ss_slabs_capacity(ss)) return; // class_idx < 0 means "unassigned" (255). Otherwise keep the requested class. uint8_t target_class = (class_idx < 0) ? 255u : (uint8_t)class_idx; TinySlabMeta* meta = &ss->slabs[slab_idx]; meta->used = 0; meta->carved = 0; meta->freelist = NULL; meta->class_idx = target_class; ss->class_map[slab_idx] = target_class; // Reset remote queue state to avoid stale pending frees on reuse. atomic_store_explicit(&ss->remote_heads[slab_idx], 0, memory_order_relaxed); atomic_store_explicit(&ss->remote_counts[slab_idx], 0, memory_order_relaxed); }