|
|||||||||||
|
Re: Eyeballs needed on new reference counted pointer template
From: Chris Frey <cdfrey(at)foursquare.net>
Date: Wed Aug 15 2007 - 04:15:08 EDT
Just some nit-pick comments. :-)
void assign(T* c)
{
detach();
if (c) {
counted_ = c;
refs_ = new size_t(1);
}
else {
counted_ = 0;
refs_ = 0;
}
}
In a very rare case, the call to: assign(new SomeObject); will leak memory if the new size_t(1) runs out of memory and throws an exception. Also, I'm more paranoid, and would probably zero the pointers in detach() anyway, just in case of that new exception. Although if new throws, we have bigger problems to worry about. :-) I usually don't even bother catching out of memory exceptions. But a library probably shouldn't leak, in case there are people who do catch out-of-mem.
-- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsub=lists@pantek.comReceived on Wed Aug 15 04:15:24 2007 This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 10:03:00 EDT |
||||||||||
|
|||||||||||