| 788 | // does NOT own the backend, so we cannot free it here. Since snapshot_free |
| 789 | // only frees buf + ctx, we accept a small leak of the lightweight cpu |
| 790 | // backend object (~64 bytes per load). For a bounded disk cache this is |
| 791 | // negligible. A proper fix would store cpu alongside the snapshot. |
| 792 | |
| 793 | return true; |
| 794 | } |
| 795 | |
| 796 | // ─── Header I/O ───────────────────────────────────────────────────────── |
| 797 | |
| 798 | bool DiskPrefixCache::write_header(FILE * f, const DiskCacheHeader & hdr) { |
| 799 | std::fwrite(hdr.magic, 1, 4, f); |
| 800 | write_u32(f, hdr.version); |
| 801 | std::fwrite(hdr.layout_id, 1, 16, f); |
| 802 | write_u32(f, hdr.cur_pos); |
| 803 | write_u32(f, hdr.n_tensors); |
| 804 | write_u32(f, hdr.token_count); |
| 805 | std::fwrite(hdr.token_hash, 1, 16, f); |
| 806 | write_u64(f, hdr.payload_bytes); |
| 807 | write_u64(f, hdr.created_at); |