bool CCachedInStream::Alloc(unsigned blockSizeLog, unsigned numBlocksLog) { unsigned sizeLog = blockSizeLog + numBlocksLog; if (sizeLog >= sizeof(size_t) * 8) return false; size_t dataSize = (size_t)1 << sizeLog; if (_data == 0 || dataSize != _dataSize) { MidFree(_data); _data = (Byte *)MidAlloc(dataSize); if (_data == 0) return false; _dataSize = dataSize; } if (_tags == 0 || numBlocksLog != _numBlocksLog) { MyFree(_tags); _tags = (UInt64 *)MyAlloc(sizeof(UInt64) << numBlocksLog); if (_tags == 0) return false; _numBlocksLog = numBlocksLog; } _blockSizeLog = blockSizeLog; return true; }
void CCachedInStream::Free() { MyFree(_tags); _tags = 0; MidFree(_data); _data = 0; }
CInFileStream::~CInFileStream() { #ifdef SUPPORT_DEVICE_FILE MidFree(Buf); #endif if (Callback) Callback->InFileStream_On_Destroy(CallbackRef); }
CInFileStream::~CInFileStream() { #ifdef SUPPORT_DEVICE_FILE MidFree(Buffer); #endif }