76 {
77 size_t bytes_from_rdbuf =
static_cast<size_t>(my->_rdbuf.sgetn(
buf.get() + offset,
len));
78 if (bytes_from_rdbuf)
79 return bytes_from_rdbuf;
80
81
82 if(
len > detail::minimum_read_size )
83 return my->_istr->readsome(
buf.get() + offset,
len);
84
85#ifndef NDEBUG
86
87
88
89 struct check_buffer_in_use {
90 bool& _buffer_in_use;
91 check_buffer_in_use(bool& buffer_in_use) : _buffer_in_use(buffer_in_use) { assert(!_buffer_in_use); _buffer_in_use = true; }
92 ~check_buffer_in_use() { assert(_buffer_in_use); _buffer_in_use = false; }
93 } buffer_in_use_checker(my->_shared_read_buffer_in_use);
94#endif
95
96 if (!my->_shared_read_buffer)
97 my->_shared_read_buffer.reset(
new char[detail::minimum_read_size], [](
char*
p){
delete[]
p; });
98 size_t bytes_read = my->_istr->readsome( my->_shared_read_buffer, detail::minimum_read_size, 0 );
99
100 size_t bytes_to_deliver_immediately = std::min<size_t>(bytes_read,
len);
101
102 memcpy(
buf.get() + offset, my->_shared_read_buffer.get(), bytes_to_deliver_immediately );
103
104 if( bytes_read >
len )
105 {
106 my->_rdbuf.sputn( my->_shared_read_buffer.get() +
len, bytes_read -
len );
107 }
108
109 return bytes_to_deliver_immediately;
110 }
memcpy((char *) pInfo->slotDescription, s, l)