diff options
author | lloyd <[email protected]> | 2014-12-09 01:53:06 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-12-09 01:53:06 +0000 |
commit | 0bc9c6b170bd2c52a2fccfda12f767700bb40968 (patch) | |
tree | 5c1328b44da71c512332442e3d36989df70ef7c7 /src/lib/compression/comp_util.cpp | |
parent | e14d04baf0261d5250285fcb6486950078b2c6e7 (diff) |
Figure out which decompressor to use based on the input file extension.
Rename Bzip to Bzip2, and split Zlib and Deflate compressors into two
completely distinct types rather than using a bool flag to the Zlib
constructor.
Ignore null pointers to our free implementation (LZMA does this).
Diffstat (limited to 'src/lib/compression/comp_util.cpp')
-rw-r--r-- | src/lib/compression/comp_util.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/compression/comp_util.cpp b/src/lib/compression/comp_util.cpp index 7fca1852d..5f2e37d49 100644 --- a/src/lib/compression/comp_util.cpp +++ b/src/lib/compression/comp_util.cpp @@ -22,13 +22,17 @@ void* Compression_Alloc_Info::do_malloc(size_t n, size_t size) void Compression_Alloc_Info::do_free(void* ptr) { - auto i = m_current_allocs.find(ptr); - if(i == m_current_allocs.end()) - throw std::runtime_error("Compression_Alloc_Info::free got pointer not allocated by us"); + if(ptr) + { + auto i = m_current_allocs.find(ptr); - std::memset(ptr, 0, i->second); - std::free(ptr); - m_current_allocs.erase(i); + if(i == m_current_allocs.end()) + throw std::runtime_error("Compression_Alloc_Info::free got pointer not allocated by us"); + + std::memset(ptr, 0, i->second); + std::free(ptr); + m_current_allocs.erase(i); + } } } |