MCPcopy Create free account
hub / github.com/buggins/coolreader / save

Method save

crengine/src/lvstream.cpp:3826–3853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3824 }
3825
3826 void save( const lUInt8 * ptr, lvpos_t pos, lvsize_t len )
3827 {
3828#if TRACE_BLOCK_WRITE_STREAM
3829 CRLog::trace("block %x save %x, %x", (int)block_start, (int)pos, (int)len);
3830#endif
3831 int offset = (int)(pos - block_start);
3832 if ( offset>size || (int)offset < 0 || len > size || (int)offset + (int)len > size ) {
3833 CRLog::error("Unaligned access to block %x", (int)block_start);
3834 }
3835 for ( unsigned i=0; i<len; i++ ) {
3836 lUInt8 ch1 = buf[offset+i];
3837 if ( pos+i>block_end || ch1!=ptr[i] ) {
3838 buf[offset+i] = ptr[i];
3839 if ( modified_start==(lvpos_t)-1 ) {
3840 modified_start = pos + i;
3841 modified_end = modified_start + 1;
3842 } else {
3843 if ( modified_start>pos+i )
3844 modified_start = pos+i;
3845 if ( modified_end<pos+i+1)
3846 modified_end = pos+i+1;
3847 if ( block_end<pos+i+1)
3848 block_end = pos+i+1;
3849 }
3850 }
3851 }
3852
3853 }
3854
3855 bool containsPos( lvpos_t pos )
3856 {

Callers 1

writeToCacheMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected