From 41eabf6ac74a7c0e81912742764ebea3d0e1fe07 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Sun, 21 Apr 2019 20:09:56 +0200 Subject: He made cc4group lazy and he saw that it was good --- src/cppc4group.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/cppc4group.cpp') diff --git a/src/cppc4group.cpp b/src/cppc4group.cpp index 04f7cef..71d9e0d 100644 --- a/src/cppc4group.cpp +++ b/src/cppc4group.cpp @@ -53,13 +53,21 @@ struct CppC4Group::MemoryManagement::Private { { auto customMemoryManagement = reinterpret_cast(arg); customMemoryManagement->referenceUsage(); + if(data == nullptr && size == 0) + { + return nullptr; + } + return customMemoryManagement->start(data, size); } static void callEndAndCleanup(void* const data, void* const arg) { auto customMemoryManagement = reinterpret_cast(arg); - customMemoryManagement->end(data); + if(data != nullptr) + { + customMemoryManagement->end(data); + } customMemoryManagement->dereferenceUsage(); } @@ -346,10 +354,10 @@ namespace { } }; -std::optional CppC4Group::getEntryInfo(const std::string& path) +std::optional CppC4Group::getEntryInfo(const std::string& path, bool lazy) { CC4Group_EntryInfo info; - if(cc4group.getEntryInfo(p->g, path.c_str(), &info)) + if(cc4group.getEntryInfo(p->g, path.c_str(), &info, lazy)) { auto entryInfo = std::make_optional(); fillEntryInfo(*entryInfo, info); @@ -361,12 +369,12 @@ std::optional CppC4Group::getEntryInfo(const std::string& } } -std::optional> CppC4Group::getEntryInfos(const std::string& path) +std::optional> CppC4Group::getEntryInfos(const std::string& path, bool lazy) { CC4Group_EntryInfo* infos; size_t infoCount; - if(cc4group.getEntryInfos(p->g, path.c_str(), &infos, &infoCount)) + if(cc4group.getEntryInfos(p->g, path.c_str(), &infos, &infoCount, lazy)) { auto entryInfos = std::make_optional>(infoCount); -- cgit v1.2.3-54-g00ecf