void Unpack::Init(byte *Window) { if (Window==NULL) { Unpack::Window = (byte*) rarmalloc( MAXWINSIZE ); if (Unpack::Window==NULL) ErrHandler.MemoryError(); } else { Unpack::Window=Window; ExternalWindow=true; } UnpInitData(false); BitInput::handle_mem_error( ErrHandler ); Inp.handle_mem_error( ErrHandler ); // Only check BitInput, as VM's memory isn't allocated yet VM.BitInput::handle_mem_error( ErrHandler ); #ifndef SFX_MODULE // RAR 1.5 decompression initialization OldUnpInitData(false); InitHuff(); #endif }
BitInput::BitInput() { InBuf = (byte*) rarmalloc( MAX_SIZE ); // Otherwise getbits() reads uninitialized memory // TODO: instead of clearing entire block, just clear last two // bytes after reading from file if ( InBuf ) memset( (char*)InBuf, 0, MAX_SIZE ); }
bool SubAllocator::StartSubAllocator(int SASize) { uint t=SASize << 20; if (SubAllocatorSize == t) return TRUE; StopSubAllocator(); uint AllocSize=t/FIXED_UNIT_SIZE*UNIT_SIZE+UNIT_SIZE; if ((HeapStart=(byte *)rarmalloc(AllocSize)) == NULL) { ErrHandler.MemoryError(); return FALSE; } HeapEnd=HeapStart+AllocSize-UNIT_SIZE; SubAllocatorSize=t; return TRUE; }
bool SubAllocator::StartSubAllocator(int SASize) { unsigned int t=SASize << 20; if (SubAllocatorSize == t) return true; StopSubAllocator(); unsigned int AllocSize=t/FIXED_UNIT_SIZE*UNIT_SIZE+UNIT_SIZE; if ((HeapStart=(unsigned char *)rarmalloc(AllocSize)) == NULL) { ErrHandler.MemoryError(); return false; } HeapEnd=HeapStart+AllocSize-UNIT_SIZE; SubAllocatorSize=t; return true; }
bool SubAllocator::StartSubAllocator(int SASize) { uint t=SASize << 20; if (SubAllocatorSize == t) return true; StopSubAllocator(); uint AllocSize=t/FIXED_UNIT_SIZE*UNIT_SIZE+UNIT_SIZE; #ifdef STRICT_ALIGNMENT_REQUIRED AllocSize+=UNIT_SIZE; #endif if ((HeapStart=(byte *)rarmalloc(AllocSize)) == NULL) { ErrHandler->MemoryError(); return false; } HeapEnd=HeapStart+AllocSize-UNIT_SIZE; SubAllocatorSize=t; return true; }
void RarVM::Init() { if (Mem==NULL) Mem = (byte*) rarmalloc( VM_MEMSIZE+4 ); }