--- parser3/src/include/pa_memory.h 2003/03/06 12:58:32 1.1.2.7 +++ parser3/src/include/pa_memory.h 2003/03/18 11:54:56 1.1.2.9 @@ -9,7 +9,9 @@ #ifndef PA_MEMORY_H #define PA_MEMORY_H -static const char* IDENT_MEMORY_H="$Date: 2003/03/06 12:58:32 $"; +static const char* IDENT_MEMORY_H="$Date: 2003/03/18 11:54:56 $"; + +#define PA_DEBUG_REFERENCES // include @@ -51,13 +53,6 @@ inline void *pa_realloc(void *ptr, size_ return pa_fail_alloc("reallocate to", size); } -// forwards - -class Exception; -class String; -class Charset; -class GdomeDOMString_auto_ptr; - template class object_ptr { T *ptr; public: @@ -205,6 +200,11 @@ public: }; +#ifdef PA_DEBUG_REFERENCES +extern const void *refdbg_this; +void pa_stack_dump(const char *msg); +#endif + /** Base for all Parser classes, memory allocation/dallocation goes via pa_malloc/pa_free. */ @@ -215,10 +215,24 @@ public: virtual ~PA_Object() {} void ref() const { +#ifdef PA_DEBUG_REFERENCES + if(this==refdbg_this) { + char buf[0x400]; + _snprintf(buf, sizeof(buf), "[0x%p#%d++]\n", this, freferences); + pa_stack_dump(buf); + } +#endif freferences++; } void unref() const { if(freferences) { +#ifdef PA_DEBUG_REFERENCES + if(this==refdbg_this) { + char buf[0x400]; + _snprintf(buf, sizeof(buf), "[0x%p#%d--]\n", this, freferences); + pa_stack_dump(buf); + } +#endif if(--freferences==0) delete this; }