use istream.ignore() for a tighter loop
This commit is contained in:
parent
818a0891a3
commit
1371d17af1
18
acn/pdu.cpp
18
acn/pdu.cpp
|
@ -176,23 +176,19 @@ void Pdu::iStream(Stream stream)
|
|||
uint hd_length = length - (flags_.hasLength ? 3 : 2) - vector_size_;
|
||||
|
||||
// abort if the remaining PDU length isn't available
|
||||
if (!stream->good() || stream->available() < hd_length) {
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
if (!stream->good() || stream->available() < hd_length)
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
|
||||
// create a stream buffer for the header and data
|
||||
stream_ = Stream(new pdu_stream(stream->data(), hd_length));
|
||||
if (stream_->available() != hd_length) {
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
if (stream_->available() != hd_length)
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
|
||||
// fast-forward the input stream
|
||||
for (uint i = 0; i < hd_length; i++)
|
||||
stream->get();
|
||||
stream->ignore(hd_length);
|
||||
|
||||
if (!stream->available())
|
||||
stream->setstate(std::ios_base::eofbit);
|
||||
return stream->setstate(std::ios_base::eofbit);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue