[classad-users] Fwd: ClassAdCollections and InitialisefromLog


Date: Mon, 12 Dec 2005 09:31:41 +0530
From: Imran Shaik <imran.sk@xxxxxxxxx>
Subject: [classad-users] Fwd: ClassAdCollections and InitialisefromLog
Hi Alain,
 Thanks !!
  I made the changes and it works fine.
  I shall come up with few more doubts in near future.

 Regards,
 Imran

On 12/8/05, Alain Roy <roy@xxxxxxxxxxx> wrote:
> You have two errors. They aren't your fault--Collections are poorly
> documented.
>
> In addition, I have on additional suggestion.
>
> >        ClassAdCollection *cac=new ClassAdCollection(true);
>
> I recommend not using the caching feature unless you want to live on the
> edge. It has barely been tested, and isn't needed unless you have too many
> ClassAds to keep in memory.
>
> >        add_classad=cac->AddClassAd("C2",mad2);
> >        cout<<"add_classad="<<add_classad<<"C2 Added"<<endl;
> >        add_classad=cac->AddClassAd("V1",mad3);
> >        cout<<"add_classad="<<add_classad<<"V1 Added"<<endl;
> >        add_classad=cac->AddClassAd("J1",jad);
> >        cout<<"add_classad="<<add_classad<<"J1 Added"<<endl;
> >
> >        add_classad=cac->AddClassAd("C3",mad2);
>
> Once you add a ClassAd to a collection, you no longer own the pointer to
> it. The collection owns it. You should not delete it, corrupt it, or give
> it to anyone else. In particular, you should not insert it into a
> collection twice. This was the cause of your segmentation fault: you
> inserted mad2 twice.
>
> >        cout<<"DISPLAY VIEW INFO"<<endl;
> >        ClassAd *c=new ClassAd();
> >        cac->GetViewInfo("resource",c);
>
> GetViewInfo will create a new ClassAd and place it into c. You therefore
> have lost the pointer to the new ClassAd you created, and it will be
> leaked. This didn't cause your crash, but it is a bug.
>
> I hope this helps.
>
> -alain
>
>
> Condor Classads Info:
> http://www.cs.wisc.edu/condor/classad/
>


--
Yours,
Imran


--
Yours,
Imran

[← Prev in Thread] Current Thread [Next in Thread→]