Pointers to Histograms

Hi everybody,
I have a problem with a root macro.
For certain reasons I create a class that has for members pointers to some
TH1F and some arrays of TH1F histograms.
This class is seen by all the function of the macro so every function can access to the common data and print, draw, access to them.
The problem is that when I load and use the macro example.C I get this error message:

root [0] .L Example.C+
Info in TUnixSystem::ACLiC: creating shared library
Example_C.so
root [1] DoSomething()
Warning in TH1::Build: Replacing existing histogram: h1 (Potential memory leak).
Warning in TH1::Build: Replacing existing histogram: h1 (Potential memory leak).
100 100.11 -0.138237 -0.139062 -0.137438
root [2] Save_data()
100 100.11
0 -0.138237

*** Break *** segmentation violation
Using host libthread_db library “/lib/tls/i686/cmov/libthread_db.so.1”.
Attaching to program: /proc/9164/exe, process 9164
[Thread debugging using libthread_db enabled]
[New Thread -1224747328 (LWP 9164)]
Failed to read a valid object file image from memory.
0xb7f26410 in ?? ()
#1 0x00000001 in ?? ()
#2 0x00000000 in ?? ()

What is the error?
Thanks to everyone!
Example.C (1.31 KB)

Please use 3 different names for the histograms (See User’s Guide chapter on Histogram and on Object Ownership).

Cheers,
Philippe.

Sorry but I don’t really understand.
If you look at the output,
you see that in the first loop on histograms root can access to the variables that I need, for the second loop it crashes…
Why ???
In the real macro the names that I use are very complex and different.

Sorry

Well … in your simple example the problem is:void DoSomething() { TH1F *histo[3]; .... my_class->histo1=histo; }where you assign the address of a local variable to your global which means that after the end of DoSomething myclass->histo1 has for all intend and purpose a random value.

Philippe