#endif
+/**
+ * All classes intended to be allocated on dump memory should extend this
+ * base class to inherit the appropriate allocation operators.
+ */
+class DumpClass {
+public:
+ void* operator new(size_t size);
+ void operator delete(void* p);
+};
+
+
/**
* Thread-local dump memory structure.
*/
// Inline functions.
+inline void* DumpClass::operator new(size_t size)
+{
+ return DumpMemory::allocate(size);
+}
+
+inline void DumpClass::operator delete(void* p)
+{
+ // We don't need to deallocate on dump memory.
+}
+
inline DumpMemory* DumpMemory::get_current()
{
// Get the DumpMemory object of the current thread.
/**
* List implementation with dump memory.
*/
-template<class T> class DumpList : protected std::list<T, DumpMemoryAllocator<T> > {
+template<class T> class DumpList :
+ public DumpClass,
+ protected std::list<T, DumpMemoryAllocator<T> > {
public:
virtual ~DumpList() {}
using std::list<T, DumpMemoryAllocator<T> >::remove;
using std::list<T, DumpMemoryAllocator<T> >::rend;
using std::list<T, DumpMemoryAllocator<T> >::size;
-
- void* operator new(size_t size) {
- return DumpMemory::allocate(size);
- }
-
- void operator delete(void* p) {}
};
#else
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/