+ storage.emplace_back();
+ Block &block = storage.back();
+ block.begin = new char[count*instance_size];
+ block.end = block.begin+count*instance_size;
+
+ size_t block_index = storage.size()-1;
+ size_t base = slots.size();
+ slots.resize(base+count);
+ for(size_t i=0; i<count; ++i)
+ {
+ Slot &slot = slots[base+i];
+ slot.next_free = base+i+1;
+ slot.block_index = block_index;
+ slot.index_in_block = i;
+ }
+
+ if(first_free>0)
+ slots[last_free].next_free = base;
+ else
+ {
+ first_free = base;
+ last_free = slots.size()-1;
+ }
+
+ slots.back().next_free = first_free;
+}
+
+size_t InstanceArrayBase::allocate()
+{
+ if(first_free<0)
+ add_block(default_count);
+
+ size_t index = first_free;
+ Slot &slot = slots[index];
+ if(first_free==last_free)
+ {
+ first_free = -1;
+ last_free = -1;
+ }
+ else
+ {
+ first_free = slot.next_free;
+ slots[last_free].next_free = first_free;
+ }
+
+ slot.used = true;
+ slot.array_index = instance_count++;
+ if(instance_data.size()<instance_count)