From: JINMEI Tatuya Date: Mon, 3 Jun 2013 05:41:43 +0000 (+0530) Subject: [2850] Assert that the segment is not grown during allMemoryDeallocated() X-Git-Tag: bind10-1.2.0beta1-release~418^2~8^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=67b935d7e7bfd22d0b7341c8e81908c9b5dd19d3;p=thirdparty%2Fkea.git [2850] Assert that the segment is not grown during allMemoryDeallocated() --- diff --git a/src/lib/util/memory_segment_mapped.cc b/src/lib/util/memory_segment_mapped.cc index f36ad71cd2..9300cae28b 100644 --- a/src/lib/util/memory_segment_mapped.cc +++ b/src/lib/util/memory_segment_mapped.cc @@ -137,7 +137,7 @@ struct MemorySegmentMapped::Impl { reserveMemory(); } - void reserveMemory() { + void reserveMemory(bool no_grow = false) { if (!read_only_) { // Reserve a named address for use during // setNamedAddress(). Though this will almost always succeed @@ -153,6 +153,7 @@ struct MemorySegmentMapped::Impl { if (reserved_storage) { break; } + assert(!no_grow); growSegment(); } @@ -332,8 +333,8 @@ MemorySegmentMapped::allMemoryDeallocated() const { impl_->freeReservedMemory(); const bool result = impl_->base_sgmt_->all_memory_deallocated(); // reserveMemory() should succeed now as the memory was already - // allocated. - impl_->reserveMemory(); + // allocated, so we set no_grow to true. + impl_->reserveMemory(true); return (result); } catch (...) { abort();