summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-08-07 14:11:16 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-08-07 14:11:16 +0000
commitef5c01ad3373fa329d5aafbc49f9fd6dfb3e55ab (patch)
treea1e677ad4ff7854e29086003543ddda4bd19e81a /src
parent09417a063607b76c9deb54cfec4c7ea42e90aae8 (diff)
2008-08-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed unmatched malloc/free. * src/IteratableChunkChecksumValidator.cc * src/IteratableChecksumValidator.cc
Diffstat (limited to 'src')
-rw-r--r--src/IteratableChecksumValidator.cc10
-rw-r--r--src/IteratableChunkChecksumValidator.cc10
2 files changed, 16 insertions, 4 deletions
diff --git a/src/IteratableChecksumValidator.cc b/src/IteratableChecksumValidator.cc
index 42231c48..1d9283a9 100644
--- a/src/IteratableChecksumValidator.cc
+++ b/src/IteratableChecksumValidator.cc
@@ -59,7 +59,11 @@ IteratableChecksumValidator::IteratableChecksumValidator(const SingleFileDownloa
IteratableChecksumValidator::~IteratableChecksumValidator()
{
+#ifdef HAVE_POSIX_MEMALIGN
+ free(_buffer);
+#else // !HAVE_POSIX_MEMALIGN
delete [] _buffer;
+#endif // !HAVE_POSIX_MEMALIGN
}
void IteratableChecksumValidator::validateChunk()
@@ -100,10 +104,12 @@ uint64_t IteratableChecksumValidator::getTotalLength() const
void IteratableChecksumValidator::init()
{
#ifdef HAVE_POSIX_MEMALIGN
+ free(_buffer);
_buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE);
-#else
+#else // !HAVE_POSIX_MEMALIGN
+ delete [] _buffer;
_buffer = new unsigned char[BUFSIZE];
-#endif // HAVE_POSIX_MEMALIGN
+#endif // !HAVE_POSIX_MEMALIGN
_pieceStorage->getDiskAdaptor()->enableDirectIO();
_currentOffset = 0;
_ctx.reset(new MessageDigestContext());
diff --git a/src/IteratableChunkChecksumValidator.cc b/src/IteratableChunkChecksumValidator.cc
index f901f0ee..00429479 100644
--- a/src/IteratableChunkChecksumValidator.cc
+++ b/src/IteratableChunkChecksumValidator.cc
@@ -66,7 +66,11 @@ IteratableChunkChecksumValidator(const DownloadContextHandle& dctx,
IteratableChunkChecksumValidator::~IteratableChunkChecksumValidator()
{
+#ifdef HAVE_POSIX_MEMALIGN
+ free(_buffer);
+#else // !HAVE_POSIX_MEMALIGN
delete [] _buffer;
+#endif // !HAVE_POSIX_MEMALIGN
}
@@ -115,10 +119,12 @@ std::string IteratableChunkChecksumValidator::calculateActualChecksum()
void IteratableChunkChecksumValidator::init()
{
#ifdef HAVE_POSIX_MEMALIGN
+ free(_buffer);
_buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE);
-#else
+#else // !HAVE_POSIX_MEMALIGN
+ delete [] _buffer;
_buffer = new unsigned char[BUFSIZE];
-#endif // HAVE_POSIX_MEMALIGN
+#endif // !HAVE_POSIX_MEMALIGN
if(_dctx->getFileEntries().size() == 1) {
_pieceStorage->getDiskAdaptor()->enableDirectIO();
}