summaryrefslogtreecommitdiff
path: root/hwpfilter
diff options
context:
space:
mode:
Diffstat (limited to 'hwpfilter')
-rw-r--r--hwpfilter/source/hstream.cxx21
-rw-r--r--hwpfilter/source/hstream.hxx11
2 files changed, 15 insertions, 17 deletions
diff --git a/hwpfilter/source/hstream.cxx b/hwpfilter/source/hstream.cxx
index 6a0d59f48048..6b5bf98cb35d 100644
--- a/hwpfilter/source/hstream.cxx
+++ b/hwpfilter/source/hstream.cxx
@@ -22,38 +22,37 @@
#include "hstream.hxx"
HStream::HStream()
- : size(0)
- , pos(0)
+ : pos(0)
{
}
-void HStream::addData(const byte *buf, int aToAdd)
+void HStream::addData(const byte *buf, size_t aToAdd)
{
- seq.resize(size + aToAdd);
- memcpy(seq.data() + size, buf, aToAdd);
- size += aToAdd;
+ seq.insert(seq.end(), buf, buf + aToAdd);
}
-int HStream::readBytes(byte * buf, int aToRead)
+size_t HStream::readBytes(byte * buf, size_t aToRead)
{
+ auto size = seq.size();
if (aToRead >= (size - pos))
aToRead = size - pos;
- for (int i = 0; i < aToRead; i++)
+ for (size_t i = 0; i < aToRead; ++i)
buf[i] = seq[pos++];
return aToRead;
}
-int HStream::skipBytes(int aToSkip)
+size_t HStream::skipBytes(size_t aToSkip)
{
+ auto size = seq.size();
if (aToSkip >= (size - pos))
aToSkip = size - pos;
pos += aToSkip;
return aToSkip;
}
-int HStream::available() const
+size_t HStream::available() const
{
- return size - pos;
+ return seq.size() - pos;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hstream.hxx b/hwpfilter/source/hstream.hxx
index 4374b92674e3..e6654f707dde 100644
--- a/hwpfilter/source/hstream.hxx
+++ b/hwpfilter/source/hstream.hxx
@@ -34,24 +34,23 @@ class HStream
/**
*
*/
- void addData( const byte *buf, int aToAdd);
+ void addData( const byte *buf, size_t aToAdd);
/**
* Read some byte to buf as given size
*/
- int readBytes( byte *buf, int aToRead);
+ size_t readBytes( byte *buf, size_t aToRead);
/**
* Skip some byte from stream as given size
*/
- int skipBytes( int aToSkip );
+ size_t skipBytes( size_t aToSkip );
/**
* @returns Size of remained stream
*/
- int available() const;
+ size_t available() const;
private:
- int size;
std::vector<byte> seq;
- int pos;
+ size_t pos;
};
#endif