[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/ricci/include counting_auto_ptr.cpp shre ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe 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<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;
 };
 
--- 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 <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
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]