Re: [ROOT] Saving a object in a ROOT file with a NULL pointer

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Jun 06 2003 - 17:35:39 MEST


Hi Pierre-Luc,

ROOT supports null pointers in I/O.
I suspect a problem with your destructor.
Make sure to reset to 0 the pointer when you delete the 
object.

As always, try to send an example as short as possible reproducing the 
problem. You and me will gain time.

Rene Brun


On 
Fri, 6 Jun 2003, Pierre-Luc 
Drouin 
wrote:

> Hi,
> 
> I've a class that contains a member variable that is a pointer to another
> object. This pointer can be NULL, if there's no need for a hold
> object. The code of my class takes it into account, with
> if(myptr!=NULL) conditions when operations on myptr have to be
> done. However, I've noticed that ROOT craches when I try to save this
> object into a ROOT file. I could use a Int_t variable 'hasptr' that would
> have a value of 0 when there's no object hold by myptr and a value of 1
> when there's one and I could indicate a size of '// [hasptr]' for ROOT in
> the header file, but this would take useless memory...
> 
> Is there a Streamer or similar ROOT function I could overload for this
> class in a way that it could handle a NULL pointer without crashing
> ROOT?
> 
> Thank you!
> 
> Pierre-Luc Drouin
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET