2008-08-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Fixed unmatched malloc/free.
	* src/IteratableChunkChecksumValidator.cc
	* src/IteratableChecksumValidator.cc
pull/1/head
Tatsuhiro Tsujikawa 2008-08-07 14:11:16 +00:00
parent 09417a0636
commit ef5c01ad33
3 changed files with 22 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2008-08-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed unmatched malloc/free.
* src/IteratableChunkChecksumValidator.cc
* src/IteratableChecksumValidator.cc
2008-08-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> 2008-08-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed max chunk size check. This change fixes BUG#2040169 Removed max chunk size check. This change fixes BUG#2040169

View File

@ -59,7 +59,11 @@ IteratableChecksumValidator::IteratableChecksumValidator(const SingleFileDownloa
IteratableChecksumValidator::~IteratableChecksumValidator() IteratableChecksumValidator::~IteratableChecksumValidator()
{ {
#ifdef HAVE_POSIX_MEMALIGN
free(_buffer);
#else // !HAVE_POSIX_MEMALIGN
delete [] _buffer; delete [] _buffer;
#endif // !HAVE_POSIX_MEMALIGN
} }
void IteratableChecksumValidator::validateChunk() void IteratableChecksumValidator::validateChunk()
@ -100,10 +104,12 @@ uint64_t IteratableChecksumValidator::getTotalLength() const
void IteratableChecksumValidator::init() void IteratableChecksumValidator::init()
{ {
#ifdef HAVE_POSIX_MEMALIGN #ifdef HAVE_POSIX_MEMALIGN
free(_buffer);
_buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE); _buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE);
#else #else // !HAVE_POSIX_MEMALIGN
delete [] _buffer;
_buffer = new unsigned char[BUFSIZE]; _buffer = new unsigned char[BUFSIZE];
#endif // HAVE_POSIX_MEMALIGN #endif // !HAVE_POSIX_MEMALIGN
_pieceStorage->getDiskAdaptor()->enableDirectIO(); _pieceStorage->getDiskAdaptor()->enableDirectIO();
_currentOffset = 0; _currentOffset = 0;
_ctx.reset(new MessageDigestContext()); _ctx.reset(new MessageDigestContext());

View File

@ -66,7 +66,11 @@ IteratableChunkChecksumValidator(const DownloadContextHandle& dctx,
IteratableChunkChecksumValidator::~IteratableChunkChecksumValidator() IteratableChunkChecksumValidator::~IteratableChunkChecksumValidator()
{ {
#ifdef HAVE_POSIX_MEMALIGN
free(_buffer);
#else // !HAVE_POSIX_MEMALIGN
delete [] _buffer; delete [] _buffer;
#endif // !HAVE_POSIX_MEMALIGN
} }
@ -115,10 +119,12 @@ std::string IteratableChunkChecksumValidator::calculateActualChecksum()
void IteratableChunkChecksumValidator::init() void IteratableChunkChecksumValidator::init()
{ {
#ifdef HAVE_POSIX_MEMALIGN #ifdef HAVE_POSIX_MEMALIGN
free(_buffer);
_buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE); _buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE);
#else #else // !HAVE_POSIX_MEMALIGN
delete [] _buffer;
_buffer = new unsigned char[BUFSIZE]; _buffer = new unsigned char[BUFSIZE];
#endif // HAVE_POSIX_MEMALIGN #endif // !HAVE_POSIX_MEMALIGN
if(_dctx->getFileEntries().size() == 1) { if(_dctx->getFileEntries().size() == 1) {
_pieceStorage->getDiskAdaptor()->enableDirectIO(); _pieceStorage->getDiskAdaptor()->enableDirectIO();
} }