Author: wyoung
Date: Thu Aug 16 12:30:28 2007
New Revision: 1752
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1752&view=rev
Log:
- Made regular ctor explicit, to prevent perverse automatic type
conversions via RefCountedPointer
- Zeroing some pointers for paranoia; not required in current code, but
future bugs may show that this is wise.
Modified:
trunk/lib/refcounted.h
Modified: trunk/lib/refcounted.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/refcounted.h?rev=1752&r1=1751&r2=1752&view=diff
==============================================================================
--- trunk/lib/refcounted.h (original)
+++ trunk/lib/refcounted.h Thu Aug 16 12:30:28 2007
@@ -56,7 +56,7 @@
/// \param c A pointer to the managed object. If you leave it at
/// its default (or pass 0 explicitly) this object is useless until
/// you vivify it with operator =() or assign().
- RefCountedPointer(T* c = 0) :
+ explicit RefCountedPointer(T* c = 0) :
counted_(c),
refs_(c ? new size_t(1) : 0)
{
@@ -174,13 +174,14 @@
/// \brief Detach ourselves from the managed memory block.
///
/// If we are managing memory, decreases the reference count and
- /// destroys the memory if the counter falls to 0. We don't zero
- /// out the pointers because none of our callers need it.
+ /// destroys the memory if the counter falls to 0.
void detach()
{
if (refs_ && (--(*refs_) == 0)) {
delete counted_;
delete refs_;
+ counted_ = 0;
+ refs_ = 0;
}
}
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits