Skip to content

Instantly share code, notes, and snippets.

@lf94
Created May 14, 2015 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lf94/47c72ed22de2f57085a8 to your computer and use it in GitHub Desktop.
Save lf94/47c72ed22de2f57085a8 to your computer and use it in GitHub Desktop.
GNU Moe's buffer data management
void Basic_buffer::add_line( const char * const buf, const int len )
{
data.back().append( buf, len );
if( data.back().size() && data.back()[data.back().size()-1] == '\n' )
{
if( data.size() >= data.capacity() && data.size() >= 10000 )
data.reserve( data.size() + ( data.size() / 10 ) );
data.push_back( std::string() );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment