Allow setting sockstreambuf buffer size and max putback#3154
Conversation
| setp(out_buffer, out_buffer + (out_buffer_size-1)); | ||
| setg(in_buffer+max_putback, | ||
| in_buffer+max_putback, | ||
| in_buffer+max_putback); | ||
| setp(out_buffer.get(), out_buffer.get() + (out_buffer_size-1)); |
There was a problem hiding this comment.
For here, should this be out_buffer + out_buffer_size? Because epptr is defined as "one past the end of the put area". If I understand this correctly, the effective buffer size will be 1 char smaller if we use out_buffer_size-1
There was a problem hiding this comment.
Yeah epptr() is one past the put area, but the final allocated byte is deliberately excluded from that put area because this implementation uses it to hold the character that triggered overflow(). So it's fine, it's just a matter of how the other parts of the code define it.
There was a problem hiding this comment.
Cool, thanks for explaining. I find the std::streambuf interface really confusing sometimes.
|
Looks good. I just fixed Thanks for another PR. |
Oh, good catch. Thanks for the help. |
I would like to use the sockstreambuf with a larger buffer size, and think it would be nice to adjust the max put back as well. In addition, I also changed the buffer pointers to unique_ptr. I figured that was just pre-C++11 code.