fix handling of keylen in walk tkeys
This commit is contained in:
parent
9bf2b1e0c5
commit
2d5d46c331
2 changed files with 15 additions and 11 deletions
|
@ -447,7 +447,7 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
|
|||
}
|
||||
}
|
||||
|
||||
// Repeated sections: allow jumping to the N-th
|
||||
// Special cases
|
||||
ImGui::ColorEdit3("_TKey Header", app.viewer.col_key, edit_flags);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("TKey Header")) {} // TODO: jump to next key
|
||||
|
@ -476,8 +476,8 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
|
|||
}
|
||||
ImGui::SameLine();
|
||||
String8 this_page_width = app.viewer.latest_page
|
||||
? push_str8f(scratch.arena, " (this page: %s)",
|
||||
to_pretty_size(scratch.arena, app.viewer.latest_page->range.len).c())
|
||||
? push_str8f(scratch.arena, " / %" PRIu64 " (this page: %s)",
|
||||
app.rndata.n_pages, to_pretty_size(scratch.arena, app.viewer.latest_page->range.len).c())
|
||||
: str8("");
|
||||
ImGui::Text("%s%s", to_pretty_size(scratch.arena, app.rndata.tot_page_comp_size).c(), this_page_width.c());
|
||||
}
|
||||
|
|
|
@ -215,7 +215,15 @@ b8 walk_tkeys(Arena *arena, const u8 *data, u64 data_len, u32 flags, TFile_Data
|
|||
fprintf(stderr, "Error: found key or obj with len 0. Bailing out...\n");
|
||||
break;
|
||||
}
|
||||
|
||||
printf("cur: 0x%lX, nbytes: %lu (/ 0x%lX)\n", cur, n_bytes, sections[Sec_TFile_FreeList].head->range.start);
|
||||
|
||||
if (is_free_slot) {
|
||||
// don't try to read the rest of the data
|
||||
cur += n_bytes;
|
||||
continue;
|
||||
}
|
||||
|
||||
u16 key_version = read_be<u16>(data + cur + key_version_off);
|
||||
u16 keylen = read_be<u16>(data + cur + keylen_off);
|
||||
if (!keylen) {
|
||||
|
@ -230,17 +238,10 @@ b8 walk_tkeys(Arena *arena, const u8 *data, u64 data_len, u32 flags, TFile_Data
|
|||
char cname[256];
|
||||
cname[cname_len] = 0;
|
||||
memcpy(cname, data + cname_off + 1, cname_len);
|
||||
printf("TKey '%s' at 0x%lX, len: %d (%s)%s\n", cname, cur, n_bytes, to_pretty_size(scratch.arena, n_bytes).c(),
|
||||
is_free_slot ? " [freed]" : "");
|
||||
printf("TKey '%s' at 0x%lX, len: %d (%s)\n", cname, cur, n_bytes, to_pretty_size(scratch.arena, n_bytes).c());
|
||||
++n_keys;
|
||||
}
|
||||
|
||||
if (is_free_slot) {
|
||||
// don't try to read the rest of the data
|
||||
cur += n_bytes;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cur == sections[Sec_TKey_List].head->range.start - sections[Sec_TKey_List].head->pre_size) {
|
||||
if (keylen != sections[Sec_TKey_List].head->pre_size ||
|
||||
(u64)(n_bytes - keylen) != sections[Sec_TKey_List].head->range.len)
|
||||
|
@ -257,6 +258,7 @@ b8 walk_tkeys(Arena *arena, const u8 *data, u64 data_len, u32 flags, TFile_Data
|
|||
} else if (cur == sections[Sec_TFile_FreeList].head->range.start) {
|
||||
sections[Sec_TFile_FreeList].head->pre_size = keylen;
|
||||
sections[Sec_TFile_FreeList].head->range.start += keylen;
|
||||
printf("keylen %lu\n", keylen);
|
||||
sections[Sec_TFile_FreeList].head->range.len = n_bytes - keylen;
|
||||
} else {
|
||||
// Check if this is a RNTuple anchor
|
||||
|
@ -346,6 +348,7 @@ b8 walk_tkeys(Arena *arena, const u8 *data, u64 data_len, u32 flags, TFile_Data
|
|||
u64 free_slots_start = sec_tfile_freelist->range.start;
|
||||
u64 free_slots_end = sec_tfile_freelist->range.end();
|
||||
u64 n_free_slots = (free_slots_end - free_slots_start) / free_slot_size;
|
||||
printf("start: 0x%lX\n", free_slots_start);
|
||||
for (u64 i = 0; i < n_free_slots; ++i) {
|
||||
u64 cur = free_slots_start + i * free_slot_size;
|
||||
memcpy(&fs, data + cur, free_slot_size);
|
||||
|
@ -364,6 +367,7 @@ b8 walk_tkeys(Arena *arena, const u8 *data, u64 data_len, u32 flags, TFile_Data
|
|||
Section *sec_free_slot = push_section(arena, tfile_data, Sec_Free_Slot);
|
||||
sec_free_slot->range.start = start;
|
||||
sec_free_slot->range.len = end - start + 1; // +1 because `end` is inclusive
|
||||
printf("free slot @0x%lX: 0x%lX - 0x%lX\n", cur, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue