summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-08-17 20:24:19 +0000
committerAlan Conway <aconway@apache.org>2007-08-17 20:24:19 +0000
commitd86b55a492b11a617e7032820bc5045f272eba7f (patch)
tree979ba0cd8b353fce4d5cd69e04a3cb2084ecadab
parentba9b6da04d4006f34b587263b6e0f449b42595de (diff)
downloadqpid-python-d86b55a492b11a617e7032820bc5045f272eba7f.tar.gz
Fix memory leak in client_test, caused by bug in Blob.h.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@567129 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--cpp/src/Makefile.am2
-rw-r--r--cpp/src/qpid/framing/Blob.h21
2 files changed, 13 insertions, 10 deletions
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am
index 32f5b3845b..a8bbe3bbf9 100644
--- a/cpp/src/Makefile.am
+++ b/cpp/src/Makefile.am
@@ -52,7 +52,7 @@ generate_MethodHolderMaxSize_h_SOURCES=generate_MethodHolderMaxSize_h.cpp
qpid/framing/MethodHolderMaxSize.h: generate_MethodHolderMaxSize_h
./generate_MethodHolderMaxSize_h
BUILT_SOURCES=qpid/framing/MethodHolderMaxSize.h
-CLEANFILES=qpid/framing/MethodHolderMaxSize.h
+DISTCLEANFILES=qpid/framing/MethodHolderMaxSize.h
## Compiler flags
diff --git a/cpp/src/qpid/framing/Blob.h b/cpp/src/qpid/framing/Blob.h
index f89bad55ea..643c4ab93d 100644
--- a/cpp/src/qpid/framing/Blob.h
+++ b/cpp/src/qpid/framing/Blob.h
@@ -99,30 +99,33 @@ class Blob
{
typedef typename TypedInPlaceFactory::value_type T;
assert(sizeof(T) <= Size);
- clear(); // Destroy old object.
factory.apply(store.address());
setType<T>();
}
+ void assign(const Blob& b) {
+ b.copy(this->get(), b.get());
+ copy = b.copy;
+ destroy = b.destroy;
+ }
+
public:
/** Construct an empty blob. */
Blob() { setType<void>(); }
/** Copy a blob. */
- Blob(const Blob& b) { *this = b; }
+ Blob(const Blob& b) { assign(b); }
/** Assign a blob */
Blob& operator=(const Blob& b) {
- setType<void>(); // Exception safety.
- b.copy(this->get(), b.get());
- copy = b.copy;
- destroy = b.destroy;
+ clear();
+ assign(b);
return *this;
}
/** @see construct() */
template<class Expr>
- Blob( const Expr & expr ) { setType<void>(); construct(expr,&expr); }
+ Blob( const Expr & expr ) { construct(expr,&expr); }
~Blob() { clear(); }
@@ -131,11 +134,11 @@ class Blob
* will construct an object using the constructor T(x,y,z)
*/
template<class Expr> void
- construct(const Expr& expr) { construct(expr,&expr); }
+ construct(const Expr& expr) { clear(); construct(expr,&expr); }
/** Copy construct an instance of T into the Blob. */
template<class T>
- Blob& operator=(const T& x) { construct(in_place<T>(x)); return *this; }
+ Blob& operator=(const T& x) { clear(); construct(in_place<T>(x)); return *this; }
/** Get pointer to blob contents. Caller must know how to cast it. */
void* get() { return store.address(); }