diff options
| author | Alan Conway <aconway@apache.org> | 2007-08-17 20:24:19 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-08-17 20:24:19 +0000 |
| commit | d86b55a492b11a617e7032820bc5045f272eba7f (patch) | |
| tree | 979ba0cd8b353fce4d5cd69e04a3cb2084ecadab /cpp/src/qpid | |
| parent | ba9b6da04d4006f34b587263b6e0f449b42595de (diff) | |
| download | qpid-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
Diffstat (limited to 'cpp/src/qpid')
| -rw-r--r-- | cpp/src/qpid/framing/Blob.h | 21 |
1 files changed, 12 insertions, 9 deletions
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(); } |
