--- parser3/src/include/pa_memory.h 2003/03/06 16:15:25 1.1.2.8 +++ 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 16:15:25 $"; +static const char* IDENT_MEMORY_H="$Date: 2003/03/18 11:54:56 $"; + +#define PA_DEBUG_REFERENCES // include @@ -198,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. */ @@ -208,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; }