diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-05-04 15:50:42 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-05-04 20:13:53 +0100 |
commit | 24736e724e98a3ed63bad5e1917f40302b1de24e (patch) | |
tree | c5941a779ac6e439a395f3ac769c8b6d8dfcad56 /hwpfilter/source/hstream.cxx | |
parent | 90911df79efe9a069c7a692d0d1109e67a1da961 (diff) |
cppcheck: memleakOnRealloc
Change-Id: Ibdf762b0d397f798372d9bf882aa82a6e5fd0229
Diffstat (limited to 'hwpfilter/source/hstream.cxx')
-rw-r--r-- | hwpfilter/source/hstream.cxx | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/hwpfilter/source/hstream.cxx b/hwpfilter/source/hstream.cxx index c9bd0d3ca066..6a0d59f48048 100644 --- a/hwpfilter/source/hstream.cxx +++ b/hwpfilter/source/hstream.cxx @@ -21,27 +21,19 @@ #include <stdlib.h> #include "hstream.hxx" -HStream::HStream() : size(0), pos(0) +HStream::HStream() + : size(0) + , pos(0) { - seq = 0; } - -HStream::~HStream() -{ - if( seq ) - free( seq ); -} - - -void HStream::addData( const byte *buf, int aToAdd) +void HStream::addData(const byte *buf, int aToAdd) { - seq = static_cast<byte *>(realloc( seq, size + aToAdd )); - memcpy( seq + size, buf, aToAdd ); + seq.resize(size + aToAdd); + memcpy(seq.data() + size, buf, aToAdd); size += aToAdd; } - int HStream::readBytes(byte * buf, int aToRead) { if (aToRead >= (size - pos)) @@ -51,7 +43,6 @@ int HStream::readBytes(byte * buf, int aToRead) return aToRead; } - int HStream::skipBytes(int aToSkip) { if (aToSkip >= (size - pos)) @@ -60,7 +51,6 @@ int HStream::skipBytes(int aToSkip) return aToSkip; } - int HStream::available() const { return size - pos; |