From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 4 Sep 2007 18:43:27 -0000 Subject: [Cluster-devel] conga/ricci/include counting_auto_ptr.cpp shre ... Message-ID: <20070904184327.26099.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: rmccabe at sourceware.org 2007-09-04 18:43:26 Modified files: ricci/include : counting_auto_ptr.cpp shred_allocator.h Log message: Add some debugging support to the counting_auto_ptr template class Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/counting_auto_ptr.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/shred_allocator.h.diff?cvsroot=cluster&r1=1.3&r2=1.4 --- conga/ricci/include/counting_auto_ptr.cpp 2007/09/04 18:30:46 1.3 +++ conga/ricci/include/counting_auto_ptr.cpp 2007/09/04 18:43:26 1.4 @@ -28,12 +28,7 @@ counting_auto_ptr::counting_auto_ptr(X* ptr) : _ptr(ptr) { - try { - _counter = 1; - } catch ( ... ) { - delete _ptr; - throw; - } + _counter = 1; try { _mutex = new Mutex(); @@ -86,7 +81,9 @@ if (last) { delete _ptr; + _ptr = NULL; delete _mutex; + _mutex = NULL; } }; @@ -95,6 +92,9 @@ X& counting_auto_ptr::operator*() const { +#ifdef DEBUG + assert(_ptr != NULL); +#endif return *_ptr; }; --- conga/ricci/include/shred_allocator.h 2007/08/31 13:32:36 1.3 +++ conga/ricci/include/shred_allocator.h 2007/09/04 18:43:26 1.4 @@ -35,20 +35,15 @@ #include - template void shred(_Tp* __p, size_t n) { - size_t size = sizeof(_Tp) / sizeof(char) * n; - if (size && __p) - for (char *ptr = (char*) __p; - ptr < ((char*) __p) + size; - ptr++) - *ptr = 'o'; + size_t size = sizeof(_Tp) / sizeof(char) * n; + if (size && __p) + memset(__p, 0, size); } - template class shred_allocator {