From 8631bb6aad20a140328dc5a22a46f646f57ce974 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Tue, 18 Jan 2011 23:42:27 -0500 Subject: [PATCH] More asserts in AlignedBuilder --- util/alignedbuilder.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/alignedbuilder.cpp b/util/alignedbuilder.cpp index 8fa487d547f..6f89e8dafc1 100644 --- a/util/alignedbuilder.cpp +++ b/util/alignedbuilder.cpp @@ -27,6 +27,8 @@ namespace mongo { uassert(13584, "out of memory AlignedBuilder", _p._allocationAddress); } + BOOST_STATIC_ASSERT(sizeof(void*) == sizeof(size_t)); + void AlignedBuilder::mallocSelfAligned(unsigned sz) { assert( sz == _p._size ); void *p = malloc(sz + Alignment - 1); @@ -35,7 +37,8 @@ namespace mongo { size_t sold = s; s += Alignment - 1; s = (s/Alignment)*Alignment; - DEV assert( s >= sold ); + assert( s >= sold ); // begining + assert( (s + sz) <= (sold + Alignment - 1) ); //end _p._data = (char *) s; }