Bug 5706 - Sharedptr dependency can be removed
Summary: Sharedptr dependency can be removed
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 420+
Hardware: Other Linux
: P4 Normal
Assignee: Maciej Stachowiak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-10 20:13 PST by George Staikos
Modified: 2005-12-19 14:10 PST (History)
0 users

See Also:


Attachments
Remove NULL from RefPtr and PassRefPtr (1.87 KB, patch)
2005-12-19 06:31 PST, Alexey Proskuryakov
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description George Staikos 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 *);
Comment 1 Alexey Proskuryakov 2005-12-19 06:31:23 PST
Created attachment 5151 [details]
Remove NULL from RefPtr and PassRefPtr
Comment 2 Darin Adler 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