public bool ReAlloc(TestAllocation alloc, int newSize, bool moveable, bool defrag) { Checked(alloc); if (!_allocator.ReAlloc(alloc.range, newSize, moveable, defrag)) { return(false); } Debug.Assert(alloc.range.Size == newSize); Debug.Assert(alloc.range.Moveable == moveable); for (uint i = (uint)alloc.size; i < newSize; i++) { _buffer[(int)(alloc.range.Position + i)] = (byte)((alloc.id + i) & 0xFF); } alloc.position = alloc.range.Position; alloc.size = newSize; alloc.moveable = moveable; Checked(alloc); CheckedAll(); return(true); }
public void Check(TestAllocation alloc) { // Check it's allocated Debug.Assert(_allocations.Contains(alloc)); // Check data still good for (uint i = 0; i < alloc.size; i++) { Debug.Assert(_buffer[(int)(alloc.position + i)] == (byte)((alloc.id + i) & 0xFF)); } }
public TestAllocation Alloc(int size, bool moveable, bool defrag) { var r = _allocator.Alloc(size, moveable, defrag); if (r == null) { if (GrowHeap(size)) { r = _allocator.Alloc(size, moveable, defrag); } if (r == null) { return(null); } } Debug.Assert(r.Size == size); Debug.Assert(r.Moveable == moveable); var alloc = new TestAllocation() { size = size, moveable = moveable, locked = false, id = _nextAllocID++, position = r.Position, range = r, }; r.User = alloc; _allocations.Add(alloc); for (uint i = 0; i < size; i++) { _buffer[alloc.position + i] = (byte)((alloc.id + i) & 0xFF); } Checked(alloc); CheckedAll(); return(alloc); }
public void Free(TestAllocation alloc) { Checked(alloc); _allocator.Free(alloc.range); _allocations.Remove(alloc); }
void Checked(TestAllocation alloc) { Check(alloc); }
public async Task <bool> Update(TestAllocation entity) { _db.TestAllocations.Update(entity); return(await Save()); }
public async Task <bool> Delete(TestAllocation entity) { _db.TestAllocations.Remove(entity); return(await Save()); }
public async Task <bool> Create(TestAllocation entity) { await _db.TestAllocations.AddAsync(entity); return(await Save()); }