Add stream avail() methods
Makes it more readable to write code that needs to know how much data/space is available in a stream.
This commit is contained in:
committed by
Lauri Kasanen
parent
910fd8fa3e
commit
7f90205cf2
@@ -129,7 +129,7 @@ size_t FdOutStream::overrun(size_t itemSize, size_t nItems)
|
||||
flush();
|
||||
|
||||
// Still not enough space?
|
||||
if (itemSize > (size_t)(end - ptr)) {
|
||||
if (itemSize > avail()) {
|
||||
// Can we shuffle things around?
|
||||
// (don't do this if it gains us less than 25%)
|
||||
if (((size_t)(sentUpTo - start) > bufSize / 4) &&
|
||||
@@ -150,7 +150,7 @@ size_t FdOutStream::overrun(size_t itemSize, size_t nItems)
|
||||
}
|
||||
|
||||
size_t nAvail;
|
||||
nAvail = (end - ptr) / itemSize;
|
||||
nAvail = avail() / itemSize;
|
||||
if (nAvail < nItems)
|
||||
return nAvail;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user