--- parser3/src/include/pa_memory.h 2003/02/21 10:58:57 1.1.2.2 +++ parser3/src/include/pa_memory.h 2003/03/06 12:58:32 1.1.2.7 @@ -9,7 +9,7 @@ #ifndef PA_MEMORY_H #define PA_MEMORY_H -static const char* IDENT_MEMORY_H="$Date: 2003/02/21 10:58:57 $"; +static const char* IDENT_MEMORY_H="$Date: 2003/03/06 12:58:32 $"; // include @@ -131,7 +131,7 @@ public: {if (this != &src) {if (ptr != src.get()) {if (owns) - delete ptr; + delete[] ptr; owns = src.owns; } else if (src.owns) owns = true; @@ -139,7 +139,7 @@ public: return (*this); } ~smart_ptr() {if (owns) - delete ptr; } + delete[] ptr; } T& operator*() const {return (*get()); } T *get() const @@ -150,11 +150,17 @@ public: operator bool() const { return get()!=0; } + bool operator !() const { + return get()==0; + } operator T*() const { return ptr; } }; +#define DECLARE_SMART_PTR(name) \ + typedef smart_ptr name##Ptr + // defines #define override @@ -165,6 +171,9 @@ public: inline void *operator new[] (size_t size) { return pa_malloc(size); } +inline void *operator new[] (size_t size, int /*zero, just flag to use calloc instead of malloc*/) { + return pa_calloc(size); +} inline void operator delete[] (void *ptr) { pa_free(ptr); } @@ -214,6 +223,7 @@ public: delete this; } } + unsigned long references() { return freferences; } }; DECLARE_OBJECT_PTR(PA_Object);