?? defaultallocator.cs
字號:
namespace Perst.Impl
{
using System;
using Perst;
public class DefaultAllocator : Persistent, CustomAllocator
{
public DefaultAllocator(Storage storage)
: base(storage)
{
}
protected DefaultAllocator() {}
public long Allocate(long size)
{
return ((StorageImpl)Storage).allocate(size, 0);
}
public long Reallocate(long pos, long oldSize, long newSize)
{
StorageImpl db = (StorageImpl)Storage;
if (((newSize + StorageImpl.dbAllocationQuantum - 1) & ~(StorageImpl.dbAllocationQuantum-1))
> ((oldSize + StorageImpl.dbAllocationQuantum - 1) & ~(StorageImpl.dbAllocationQuantum-1)))
{
long newPos = db.allocate(newSize, 0);
db.cloneBitmap(pos, oldSize);
db.free(pos, oldSize);
pos = newPos;
}
return pos;
}
public void Free(long pos, long size)
{
((StorageImpl)Storage).cloneBitmap(pos, size);
}
public void Commit() {}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -