void CCircBuf::Defrag() { // Lock the buffer oexAutoLock ll( &m_lock ); if ( !ll.IsLocked() ) return; if ( !m_pBi ) return; // Set the pointers back to zero if the buffer is empty if ( m_pBi->uReadPtr == NormalizePtr( m_pBi->uWritePtr, m_uSize ) ) Empty(); }
void InfoManager::Dump() { uint32_t pos; for(size_t i=0;i<infovec.Size();i++) { infovec.Load(i,&pos); DF_info inf; peekarb(pos,&inf,sizeof(inf)); if(inf.InfoType()!="") cout<<inf.InfoType()<<":"<<inf.ID<<endl; else cout<<hex<<NormalizePtr(inf.vtable)<<dec<<":"<<inf.ID<<endl; } }
oexBOOL CCircBuf::Read( oexPVOID x_pvBuf, t_size x_uMax, t_size *x_puRead, t_size *x_puPtr, oexUINT x_uEncode ) { // Lock the buffer oexAutoLock ll( &m_lock ); if ( !ll.IsLocked() ) return oexFALSE; if ( !m_pBi ) return oexFALSE; // Where to start? t_size uPtr = NormalizePtr( x_puPtr ? *x_puPtr : 0, m_uSize ); // Anything to read? t_size uSize = GetMaxRead( uPtr, m_pBi->uWritePtr, m_uSize ); if ( !uSize ) return oexFALSE; // Do they just want to know the size? if ( x_pvBuf == oexNULL || x_uMax == 0 ) { if ( x_puRead ) *x_puRead = uSize; return oexTRUE; } // end if // Are we short a few bytes? if ( uSize < x_uMax ) { // Assume we MUST read dwMax if we can't tell the user otherwise if ( x_puRead == oexNULL ) return oexFALSE; } // end if // Do we have more than enough? else if ( uSize > x_uMax ) { // Truncate to user buffer uSize = x_uMax; } // end else oexUCHAR *pView = oexNULL; t_size i = 0, uRead = 0, uView; // Read all the blocks into the buffer while ( GetView( i, uPtr, uSize, m_pBuf, m_uSize, &pView, &uView ) ) { // Copy the data os::CSys::MemCpy( &( (oexUCHAR*)x_pvBuf )[ uRead ], pView, uView ); // Decode if needed if ( x_uEncode ) OnDecode( x_uEncode, i, &( (oexUCHAR*)x_pvBuf )[ uRead ], uView ); // For inspecting the actual read data OnInspectRead( i, pView, uView ); // Keep count of the bytes read uRead += uView; // Next block i++; } // end while // Update the pointer if required if ( x_puPtr ) *x_puPtr = NormalizePtr( AdvancePtr( uPtr, uSize, m_uSize ), m_uSize ); // How many bytes were read? if ( x_puRead ) *x_puRead = uRead; return oexTRUE; }