virtual void bytesReady( size_t offset, const dp::Data& data, bool eof ) { if( !data.isNull() ) { size_t buflen; const unsigned char * buf = data.data(&buflen); if (offset != data_bytes_read_) { reportError("Stream received non-sequentially"); return; } if (data_capacity_ < data_bytes_read_ + buflen) { data_capacity_ = data_bytes_read_ + buflen; unsigned char * tmp = new unsigned char[data_capacity_]; if (data_read_) { ::memcpy(tmp, data_read_, data_bytes_read_); delete[] data_read_; } data_read_ = tmp; } memcpy(data_read_ + data_bytes_read_, buf, buflen); data_bytes_read_ += buflen; } }
virtual void bytesReady( size_t offset, const dp::Data& data, bool eof ) { if( !data.isNull() ) { size_t buflen; const unsigned char * buf = data.data(&buflen); if (offset != m_DataBytesRead) { reportError("Stream received non-sequentially"); return; } if (m_DataCapacity < m_DataBytesRead + buflen) { m_DataCapacity = m_DataBytesRead + buflen; unsigned char * tmp = new unsigned char[m_DataCapacity]; if (m_pDataRead) { ::memcpy(tmp, m_pDataRead, m_DataBytesRead); delete[] m_pDataRead; } m_pDataRead = tmp; } if( m_verbose ) reportData( "out", offset, data ); memcpy(m_pDataRead + m_DataBytesRead, buf, buflen); m_DataBytesRead += buflen; } }