public static void Free( IntPtr pointer )
{
lock ( memoryBlocks )
{
// find the memory block in cache
for ( int i = 0; i < currentCacheSize; i++ )
{
if ( memoryBlocks[i].MemoryBlock == pointer )
{
// mark the block as free
memoryBlocks[i].Free = true;
busyBlocks--;
return;
}
}
// the block was not cached, so lets just free it
Marshal.FreeHGlobal( pointer );
}
}