Beispiel #1
0
 void track_deallocate(void* ptr, std::size_t n, std::size_t size, int tag)
 {
     BOOST_DEDUCED_TYPENAME allocated_memory_type::iterator pos
         = allocated_memory.find(memory_area(ptr, (char*) ptr + n * size));
     if(pos == allocated_memory.end()) {
         BOOST_ERROR("Deallocating unknown pointer.");
     } else {
         BOOST_TEST(pos->first.start == ptr);
         BOOST_TEST(pos->first.end == (char*) ptr + n * size);
         BOOST_TEST(pos->second.tag_ == tag);
         allocated_memory.erase(pos);
     }
     BOOST_TEST(count_allocations > 0);
     if(count_allocations > 0) --count_allocations;
 }
Beispiel #2
0
 void allocator_ref()
 {
     if(count_allocators == 0) {
         count_allocations = 0;
         count_constructions = 0;
         allocated_memory.clear();
     }
     ++count_allocators;
 }
Beispiel #3
0
            void allocator_unref()
            {
                BOOST_TEST(count_allocators > 0);
                if(count_allocators > 0) {
                    --count_allocators;
                    if(count_allocators == 0) {
                        bool no_allocations_left = (count_allocations == 0);
                        bool no_constructions_left = (count_constructions == 0);
                        bool allocated_memory_empty = allocated_memory.empty();

                        // Clearing the data before the checks terminate the tests.
                        count_allocations = 0;
                        count_constructions = 0;
                        allocated_memory.clear();

                        BOOST_TEST(no_allocations_left);
                        BOOST_TEST(no_constructions_left);
                        BOOST_TEST(allocated_memory_empty);
                    }
                }
            }
Beispiel #4
0
 void track_allocate(void *ptr, std::size_t n, std::size_t size, int tag)
 {
     if(n == 0) {
         BOOST_ERROR("Allocating 0 length array.");
     }
     else {
         ++count_allocations;
         allocated_memory.insert(
             std::pair<memory_area const, memory_track>(
                 memory_area(ptr, (char*) ptr + n * size),
                 memory_track(tag)));
     }
 }