From c588b9572eb09f00fa4a79340224f44a7bf3bf71 Mon Sep 17 00:00:00 2001 From: Daniel Schemmel Date: Fri, 19 May 2023 22:29:04 +0000 Subject: add unsized free to kdalloc --- include/klee/KDAlloc/allocator.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/klee/KDAlloc/allocator.h b/include/klee/KDAlloc/allocator.h index 1e0d305a..4ed76705 100644 --- a/include/klee/KDAlloc/allocator.h +++ b/include/klee/KDAlloc/allocator.h @@ -143,6 +143,20 @@ public: return result; } + void free(void *ptr) { + assert(*this && "Invalid allocator"); + assert(ptr && "Freeing nullptrs is not supported"); // we are not ::free! + + auto bin = control->convertPtrToBinIndex(ptr); + traceLine("Freeing ", ptr, " in bin ", bin); + + if (bin < static_cast(sizedBins.size())) { + return sizedBins[bin].deallocate(control->sizedBins[bin], ptr); + } else { + return largeObjectBin.deallocate(control->largeObjectBin, ptr); + } + } + void free(void *ptr, std::size_t size) { assert(*this && "Invalid allocator"); assert(ptr && "Freeing nullptrs is not supported"); // we are not ::free! -- cgit 1.4.1