inline void CheckAllocator(MyTable &table, size_t expected_allocs, size_t expected_frees, bool exact = true) { size_t items_allocated = table.get_allocator().items_allocated, items_freed = table.get_allocator().items_freed; size_t allocations = table.get_allocator().allocations, frees = table.get_allocator().frees; REMARK("checking allocators: items %u/%u, allocs %u/%u\n", unsigned(items_allocated), unsigned(items_freed), unsigned(allocations), unsigned(frees) ); ASSERT( items_allocated == allocations, NULL); ASSERT( items_freed == frees, NULL); if(exact) { ASSERT( allocations == expected_allocs, NULL); ASSERT( frees == expected_frees, NULL); } else { ASSERT( allocations >= expected_allocs, NULL); ASSERT( frees >= expected_frees, NULL); ASSERT( allocations - frees == expected_allocs - expected_frees, NULL ); } }
inline void CheckAllocator(MyTable &table, size_t expected_allocs, size_t expected_frees, bool exact = true, int line = 0) { typename MyTable::allocator_type a = table.get_allocator(); REMARK("#%d checking allocators: items %u/%u, allocs %u/%u\n", line, unsigned(a.items_allocated), unsigned(a.items_freed), unsigned(a.allocations), unsigned(a.frees) ); ASSERT( a.items_allocated == a.allocations, NULL); ASSERT( a.items_freed == a.frees, NULL); if(exact) { ASSERT( a.allocations == expected_allocs, NULL); ASSERT( a.frees == expected_frees, NULL); } else { ASSERT( a.allocations >= expected_allocs, NULL); ASSERT( a.frees >= expected_frees, NULL); ASSERT( a.allocations - a.frees == expected_allocs - expected_frees, NULL ); } }