MCPcopy Create free account
hub / github.com/SatDump/SatDump / TableBeginInitMemory

Method TableBeginInitMemory

src-core/imgui/imgui_tables.cpp:597–616  ·  view source on GitHub ↗

For reference, the average total _allocation count_ for a table is: + 0 (for ImGuiTable instance, we are pooling allocations in g.Tables[]) + 1 (for table->RawData allocated below) + 1 (for table->ColumnsNames, if names are used) Shared allocations for the maximum number of simultaneously nested tables (generally a very small number) + 1 (for table->Splitter._Channels) + 2 * active_channels_count

Source from the content-addressed store, hash-verified

595// Where active_channels_count is variable but often == columns_count or == columns_count + 1, see TableSetupDrawChannels() for details.
596// Unused channels don't perform their +2 allocations.
597void ImGui::TableBeginInitMemory(ImGuiTable* table, int columns_count)
598{
599 // Allocate single buffer for our arrays
600 const int columns_bit_array_size = (int)ImBitArrayGetStorageSizeInBytes(columns_count);
601 ImSpanAllocator<6> span_allocator;
602 span_allocator.Reserve(0, columns_count * sizeof(ImGuiTableColumn));
603 span_allocator.Reserve(1, columns_count * sizeof(ImGuiTableColumnIdx));
604 span_allocator.Reserve(2, columns_count * sizeof(ImGuiTableCellData), 4);
605 for (int n = 3; n < 6; n++)
606 span_allocator.Reserve(n, columns_bit_array_size);
607 table->RawData = IM_ALLOC(span_allocator.GetArenaSizeInBytes());
608 memset(table->RawData, 0, span_allocator.GetArenaSizeInBytes());
609 span_allocator.SetArenaBasePtr(table->RawData);
610 span_allocator.GetSpan(0, &table->Columns);
611 span_allocator.GetSpan(1, &table->DisplayOrderToIndex);
612 span_allocator.GetSpan(2, &table->RowCellData);
613 table->EnabledMaskByDisplayOrder = (ImU32*)span_allocator.GetSpanPtrBegin(3);
614 table->EnabledMaskByIndex = (ImU32*)span_allocator.GetSpanPtrBegin(4);
615 table->VisibleMaskByIndex = (ImU32*)span_allocator.GetSpanPtrBegin(5);
616}
617
618// Apply queued resizing/reordering/hiding requests
619void ImGui::TableBeginApplyRequests(ImGuiTable* table)

Callers

nothing calls this directly

Calls 6

GetArenaSizeInBytesMethod · 0.80
SetArenaBasePtrMethod · 0.80
GetSpanMethod · 0.80
GetSpanPtrBeginMethod · 0.80
ReserveMethod · 0.45

Tested by

no test coverage detected