From 0546553f2dd94125cd6ee450592bc396c43256ec Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 9 Nov 2019 02:57:36 -0500 Subject: [PATCH] IOStreams: Replace CZipSupport with lambda functions We can safely replace the class with direct lambda functions, given they don't need to capture any state. --- Runtime/IOStreams.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Runtime/IOStreams.cpp b/Runtime/IOStreams.cpp index 4bf6a875f..39ba621a0 100644 --- a/Runtime/IOStreams.cpp +++ b/Runtime/IOStreams.cpp @@ -109,18 +109,12 @@ void CBitStreamWriter::Flush() { x14_val = 0; } -class CZipSupport { -public: - static void* Alloc(void*, u32 c, u32 n) { return new u8[c * n]; } - static void Free(void*, void* buf) { delete[] static_cast(buf); } -}; - CZipInputStream::CZipInputStream(std::unique_ptr&& strm) : x24_compBuf(new u8[4096]), x28_strm(std::move(strm)) { x30_zstrm.next_in = x24_compBuf.get(); x30_zstrm.avail_in = 0; - x30_zstrm.zalloc = CZipSupport::Alloc; - x30_zstrm.zfree = CZipSupport::Free; + x30_zstrm.zalloc = [](void*, u32 c, u32 n) -> void* { return new u8[size_t{c} * size_t{n}]; }; + x30_zstrm.zfree = [](void*, void* buf) { delete[] static_cast(buf); }; inflateInit(&x30_zstrm); }