conga/ricci/include counting_auto_ptr.cpp shre ...
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
ricci/include/counting_auto_ptr.cpp +6 -6
@@ -28,12 +28,7 @@ counting_auto_ptr<X>::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<X>::operator*() const { +#ifdef DEBUG + assert(_ptr != NULL); +#endif return *_ptr; };
ricci/include/shred_allocator.h +3 -8
@@ -35,20 +35,15 @@#include <new> - template<typename _Tp> 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<typename _Tp> class shred_allocator {