summaryrefslogtreecommitdiff
path: root/indra/llcorehttp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcorehttp')
-rwxr-xr-xindra/llcorehttp/_refcounted.h19
-rwxr-xr-xindra/llcorehttp/bufferarray.h2
-rwxr-xr-xindra/llcorehttp/httpheaders.h2
-rwxr-xr-xindra/llcorehttp/httpoptions.h2
4 files changed, 22 insertions, 3 deletions
diff --git a/indra/llcorehttp/_refcounted.h b/indra/llcorehttp/_refcounted.h
index cd16e2e2b4..7f713f2298 100755
--- a/indra/llcorehttp/_refcounted.h
+++ b/indra/llcorehttp/_refcounted.h
@@ -32,6 +32,7 @@
#include "fix_macros.h"
#include <boost/thread.hpp>
+#include <boost/intrusive_ptr.hpp>
#include "llapr.h"
@@ -120,6 +121,24 @@ inline void RefCounted::destroySelf()
delete this;
}
+/**
+ * boost::intrusive_ptr may be used to manage RefCounted classes.
+ * Unfortunately RefCounted and boost::intrusive_ptr use different conventions
+ * for the initial refcount value. To avoid leaky (immortal) objects, you
+ * should really construct boost::intrusive_ptr<RefCounted*>(rawptr, false).
+ * IntrusivePtr<T> encapsulates that for you.
+ */
+template <typename T>
+struct IntrusivePtr: public boost::intrusive_ptr<T>
+{
+ IntrusivePtr():
+ boost::intrusive_ptr<T>()
+ {}
+ IntrusivePtr(T* p):
+ boost::intrusive_ptr<T>(p, false)
+ {}
+};
+
inline void intrusive_ptr_add_ref(RefCounted* p)
{
p->addRef();
diff --git a/indra/llcorehttp/bufferarray.h b/indra/llcorehttp/bufferarray.h
index 076f341736..320adf2b8b 100755
--- a/indra/llcorehttp/bufferarray.h
+++ b/indra/llcorehttp/bufferarray.h
@@ -74,7 +74,7 @@ public:
BufferArray();
- typedef boost::intrusive_ptr<BufferArray> ptr_t;
+ typedef LLCoreInt::IntrusivePtr<BufferArray> ptr_t;
protected:
virtual ~BufferArray(); // Use release()
diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h
index 51bd76a01d..8f14568fa3 100755
--- a/indra/llcorehttp/httpheaders.h
+++ b/indra/llcorehttp/httpheaders.h
@@ -92,7 +92,7 @@ public:
/// the instance.
HttpHeaders();
- typedef boost::intrusive_ptr<HttpHeaders> ptr_t;
+ typedef LLCoreInt::IntrusivePtr<HttpHeaders> ptr_t;
protected:
virtual ~HttpHeaders(); // Use release()
diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h
index 21ecff85af..2fe05a65ff 100755
--- a/indra/llcorehttp/httpoptions.h
+++ b/indra/llcorehttp/httpoptions.h
@@ -60,7 +60,7 @@ class HttpOptions : public LLCoreInt::RefCounted
public:
HttpOptions();
- typedef boost::intrusive_ptr<HttpOptions> ptr_t;
+ typedef LLCoreInt::IntrusivePtr<HttpOptions> ptr_t;
protected:
virtual ~HttpOptions(); // Use release()