cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/ricci/include counting_auto_ptr.cpp shre ...
Date: 4 Sep 2007 18:43:27 -0000	[thread overview]
Message-ID: <20070904184327.26099.qmail@sourceware.org> (raw)

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
 {



                 reply	other threads:[~2007-09-04 18:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070904184327.26099.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).