MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / reserve

Function reserve

extern/imgui/imgui.h:1877–1877  ·  view source on GitHub ↗

Resize a vector to a smaller size, guaranteed not to cause a reallocation

Source from the content-addressed store, hash-verified

1875 inline void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; }
1876 inline void shrink(int new_size) { IM_ASSERT(new_size <= Size); Size = new_size; } // Resize a vector to a smaller size, guaranteed not to cause a reallocation
1877 inline void reserve(int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)IM_ALLOC((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); IM_FREE(Data); } Data = new_data; Capacity = new_capacity; }
1878 inline void reserve_discard(int new_capacity) { if (new_capacity <= Capacity) return; if (Data) IM_FREE(Data); Data = (T*)IM_ALLOC((size_t)new_capacity * sizeof(T)); Capacity = new_capacity; }
1879
1880 // NB: It is illegal to call push_back/push_front/insert with a reference pointing inside the ImVector data itself! e.g. v.push_back(v[10]) is forbidden.

Callers 4

resizeFunction · 0.70
push_backFunction · 0.70
insertFunction · 0.70
resizeMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected