Hi Marco, You should not use the form array[i] = new object, but instead array->Add(object) or array->AddAt(object,i); We still allow the use of array[i] = object (we may disable this in the future) The problem is that you may fill the array in any order. When this is the case the internal member fLast is not updated because we do not want to update this member when doing the authorized form object = array[i]. In your case, fLast was never updated and in TObjArray::Streamer, we save all objects from to to fLast (equal -1 in your case). One could recompute fLast in the Streamer function. However, we see many cases of very large TObjArray filled with only a few elements. The current algorithm saves a lot of time during the I/O. Rene Brun Marco van Leeuwen wrote: > > Hi rooters, > > I just started using root v3.02 instead of v2.25, and I found that some > of my macros no longer work. I traced it down to some mysterious > behaviour when writing a TObjArray to a file, using a single key. It > turns out that there is a big difference between writing a dynamically > allocated array vs. a 'statically allocated' one. I attached two macros > to illustrate the problem. First execute write_arr.C to make a file with > two arrays, one dynamically allocated, the other one statically. Using > read_arr.C to read them back in gives a surprising result: one of the > two arrays is empty (the statically aloocated array). > > Did I do something wrong? Or is there something inconsistent in ROOT or > CINT ? > > Best regards, > > Marco van Leeuwen. > > -------------------------------------------------------------------------------- > > Name: write_arr.C > write_arr.C Type: Plain Text (text/plain) > Encoding: 7bit > > Name: read_arr.C > read_arr.C Type: Plain Text (text/plain) > Encoding: 7bit
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:09 MET