boost::streambuf default size/capacity still set to 128 in spite of size provided in constructor.
Hello, I was checking the implementation of boost streambuf and noticed that buffer_delta value is defaulted to 128, which results in the capacity of the container to 128 bytes by default, and based on that, there is no way to change it even if we provide max size as some custom number (say 1500 for receiving a packet on socket). The initial allocation (buffer_.resize is done with 128. But when we call *buf.prepare(1500)*, it again results in resize(n) operation (through reserve(n) function call. Is there any other way to change this other than modifying the constructor in our codebase to provide a user defined value of buffer_delta Not sure if this needs to be enhanced. the maximum_size argument seems to be of no use in this case... Kindly advise. Regards Aniket. /// Construct a basic_streambuf object. /** * Constructs a streambuf with the specified maximum size. The initial size * of the streambuf's input sequence is 0. */ explicit basic_streambuf( std::size_t maximum_size = (std::numeric_limitsstd::size_t::max)(), const Allocator& allocator = Allocator()) : max_size_(maximum_size), buffer_(allocator) { *std::size_t pend = (std::minstd::size_t)(max_size_, buffer_delta);* *buffer_.resize((std::maxstd::size_t)(pend, 1));* setg(&buffer_[0], &buffer_[0], &buffer_[0]); setp(&buffer_[0], &buffer_[0] + pend); } -- Thanks and regards, Aniket Pugaonkar
participants (1)
-
Aniket Pugaonkar