RESOLVED FIXED 5706
Sharedptr dependency can be removed
https://bugs.webkit.org/show_bug.cgi?id=5706
Summary Sharedptr dependency can be removed
George Staikos
Reported 2005-11-10 20:13:26 PST
SharedPtr doesn't compile on its own. It would need includes for NULL. This causes failures in some configurations. A better solution in my opinion is to change NULL to 0: @@ -29,7 +29,7 @@ template <class T> class SharedPtr { public: - SharedPtr() : m_ptr(NULL) {} + SharedPtr() : m_ptr(0) {} SharedPtr(T *ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); } SharedPtr(const SharedPtr &o) : m_ptr(o.m_ptr) { if (T *ptr = m_ptr) ptr->ref(); } ~SharedPtr() { if (T *ptr = m_ptr) ptr->deref(); } @@ -37,11 +37,11 @@ template <class U> SharedPtr(const SharedPtr<U> &o) : m_ptr(o.get()) { if (T *ptr = m_ptr) ptr->ref(); } // FIXME: Deprecate in favor of operators below, then remove? - bool isNull() const { return m_ptr == NULL; } - bool notNull() const { return m_ptr != NULL; } + bool isNull() const { return m_ptr == 0; } + bool notNull() const { return m_ptr != 0; } // FIXME: Deprecate in favor of operator=, then remove? - void reset() { if (T *ptr = m_ptr) ptr->deref(); m_ptr = NULL; } + void reset() { if (T *ptr = m_ptr) ptr->deref(); m_ptr = 0; } void reset(T *o) { if (o) o->ref(); if (T *ptr = m_ptr) ptr->deref(); m_ptr = o; } T *get() const { return m_ptr; } @@ -49,8 +49,8 @@ T &operator*() const { return *m_ptr; } T *operator->() const { return m_ptr; } - bool operator!() const { return m_ptr == NULL; } - operator bool() const { return m_ptr != NULL; } + bool operator!() const { return m_ptr == 0; } + operator bool() const { return m_ptr != 0; } SharedPtr &operator=(const SharedPtr &); SharedPtr &operator=(T *);
Attachments
Remove NULL from RefPtr and PassRefPtr (1.87 KB, patch)
2005-12-19 06:31 PST, Alexey Proskuryakov
darin: review+
Alexey Proskuryakov
Comment 1 2005-12-19 06:31:23 PST
Created attachment 5151 [details] Remove NULL from RefPtr and PassRefPtr
Darin Adler
Comment 2 2005-12-19 08:49:28 PST
Comment on attachment 5151 [details] Remove NULL from RefPtr and PassRefPtr Good idea. I had put this in my local copy already. Although for operator! I think that !m_ptr is even better than m_ptr == 0. r=me
Note You need to log in before you can comment on or make changes to this bug.