void leaf_data::add_reference( uint32_t ref ) { //logfile() << format( "leaf_data[%s]::add_reference( %s )\n" ) % idx_ % ref; assert( can_add( ref ) ); if ( has_reference( ref ) ) return; iterator first = begin(); const iterator past = end(); unsigned value = 0; while ( first != past ) { value = *first; ++first; } ++ref; if ( usedbytes() ) ++value; unsigned char* target = const_cast<unsigned char*>( first.raw() ); assert( target == my_base() + usedbytes() ); if ( ref > value && ( ref - value ) < 256 ) { assert( ref != value ); *target = ref - value; set_usedbytes( usedbytes() + 1 ); } else { *target++ = 0; byte_io::write<uint32_t>( target, ref ); set_usedbytes( usedbytes() + 1 + byte_io::byte_lenght<uint32_t>() ); } assert( usedbytes() <= capacity() ); }
int main() { char *str = "HELLO"; my_verif(str); my_base(); return (0); }
void leaf_data::grow() { set_capacity( ( next_byte_size() - data_offset ) ); memset( my_base() + usedbytes(), 0, capacity() - usedbytes() ); }