texmacs-dev
[Top][All Lists]
Advanced

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

Re: [Texmacs-dev] [PATCH] solves GCC 3.2 auto_save segfault for me...


From: Igor V. Kovalenko
Subject: Re: [Texmacs-dev] [PATCH] solves GCC 3.2 auto_save segfault for me...
Date: Tue, 05 Nov 2002 13:21:41 +0300
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020809

Joris van der Hoeven wrote:
+//void destroy_tree_rep (tree_rep* rep);
 inline tree::tree (const tree& x): rep (x.rep) { rep->ref_count++; }
-inline tree::~tree () {
-  if ((--rep->ref_count)==0) destroy_tree_rep (rep); }
+
+inline tree::~tree ()
+{
+    if ((--rep->ref_count)==0) {
+        //destroy_tree_rep (rep);
+        delete rep;
+        rep = NULL;
+    }
+}

I am a bit confused by this. Is this necessary?
We should recursively delete the tree,
so it does not suffice to just delete the pointer...


I see now; that is the purpose of the virtual destructor...

But now I am again confused, because the old routine
destroy_tree_rep should precisely do the same thing
as the virtual destructor. Apparently, a string is sometimes
not a string or a compound not a compound...

By the way, what is the effect of "rep = NULL" ?
This is the only real change I can see,
but I do not see why this should stabilize the code.

BTW the real change is in removing destroy_tree_rep that dereferences a rep 
itself,
and in using the presumed automagic of virtual destructors to do the job.

Can you do the test: in internal deallocator poison the data freed but not 
deallocated
with some non-zero values, say, 0xdeadbeef or something, and see the effect?

--
Regards,
Igor V. Kovalenko    mailto: iko at crec dot mipt dot ru





reply via email to

[Prev in Thread] Current Thread [Next in Thread]