You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2007/08/17 22:24:20 UTC
svn commit: r567129 - in /incubator/qpid/trunk/qpid/cpp/src: Makefile.am
qpid/framing/Blob.h
Author: aconway
Date: Fri Aug 17 13:24:19 2007
New Revision: 567129
URL: http://svn.apache.org/viewvc?view=rev&rev=567129
Log:
Fix memory leak in client_test, caused by bug in Blob.h.
Modified:
incubator/qpid/trunk/qpid/cpp/src/Makefile.am
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h
Modified: incubator/qpid/trunk/qpid/cpp/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/Makefile.am?view=diff&rev=567129&r1=567128&r2=567129
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/Makefile.am Fri Aug 17 13:24:19 2007
@@ -52,7 +52,7 @@
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
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h?view=diff&rev=567129&r1=567128&r2=567129
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h Fri Aug 17 13:24:19 2007
@@ -99,30 +99,33 @@
{
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 @@
* 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(); }