00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PPL_ppl_prolog_common_inlines_hh
00025 #define PPL_ppl_prolog_common_inlines_hh 1
00026
00027 #if PROLOG_TRACK_ALLOCATION || NOISY_PROLOG_TRACK_ALLOCATION
00028
00029 #include <typeinfo>
00030 #include <iomanip>
00031
00032 template <typename T>
00033 void
00034 Allocation_Tracker::insert(const T* p) {
00035 #if NOISY_PROLOG_TRACK_ALLOCATION
00036 std::cerr << "inserting " << typeid(*p).name()
00037 << " at " << std::hex << (void*) p << std::endl;
00038 #endif
00039 std::pair<Set::iterator, bool> stat = s.insert(p);
00040 if (!stat.second) {
00041 std::cerr << "Interfaces::Prolog::Allocation_Tracker:"
00042 " two objects at the same address at the same time?!"
00043 << std::endl;
00044 abort();
00045 }
00046 }
00047
00048 template <typename T>
00049 void
00050 Allocation_Tracker::weak_insert(const T* p) {
00051 #if NOISY_PROLOG_TRACK_ALLOCATION
00052 std::cerr << "inserting weak " << typeid(*p).name()
00053 << " at " << std::hex << (void*) p << std::endl;
00054 #endif
00055 weak_s.insert(p);
00056 }
00057
00058 template <typename T>
00059 void
00060 Allocation_Tracker::remove(const T* p) {
00061 #if NOISY_PROLOG_TRACK_ALLOCATION
00062 std::cerr << "removing " << typeid(*p).name()
00063 << " at " << std::hex << (void*) p << std::endl;
00064 #endif
00065 if (s.erase(p) != 1) {
00066 std::cerr << "Interfaces::Prolog::Allocation_Tracker:"
00067 " attempt to deallocate a nonexistent polyhedron."
00068 << std::endl;
00069 abort();
00070 }
00071 }
00072
00073 template <typename T>
00074 void
00075 Allocation_Tracker::check(const T* p) const {
00076 if (s.find(p) == s.end()
00077 && weak_s.find(p) == weak_s.end()) {
00078 std::cerr << "Interfaces::Prolog::Allocation_Tracker:"
00079 " attempt to access a nonexistent "
00080 << typeid(*p).name()
00081 << " at " << std::hex << (void*) p << std::endl;
00082 abort();
00083 }
00084 }
00085
00086 #endif // PROLOG_TRACK_ALLOCATION || NOISY_PROLOG_TRACK_ALLOCATION
00087
00088 #endif // !defined(PPL_ppl_prolog_common_inlines_hh)