cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] conga/ricci/include counting_auto_ptr.cpp shre ...
@ 2007-09-04 18:43 rmccabe
  0 siblings, 0 replies; only message in thread
From: rmccabe @ 2007-09-04 18:43 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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<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
 {



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-09-04 18:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-04 18:43 [Cluster-devel] conga/ricci/include counting_auto_ptr.cpp shre rmccabe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).