Coverity:
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 12 Apr 2011 13:57:20 +0000 (13:57 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 12 Apr 2011 13:57:20 +0000 (13:57 +0000)
AliHelix.cxx    - dead code
TTreeStream.cxx - sprintf =>snprintf
AliSplineFit.cxx  - sprintf
+
AliSysInfo.cxx   - adding static function to estimate  the size of object in memory

Marian

STEER/AliHelix.cxx
STEER/AliSplineFit.cxx
STEER/AliSysInfo.cxx
STEER/AliSysInfo.h
STEER/TTreeStream.cxx

index a1f6330..2e0904a 100644 (file)
@@ -532,12 +532,12 @@ Int_t  AliHelix::ParabolicDCA(AliHelix&h,  //helixes
       dd=dx*dx/dx2 + dy*dy/dy2 + dz*dz/dz2;
       if (dd<dm) break;
       dt1*=0.5; dt2*=0.5;
-      if (div==0){
-       div =1;
-      }
-      if (div>512) {     
-       break;
-      }   
+  //     if (div==0){
+//     div =1;
+//       }
+//       if (div>512) {          
+//     break;
+//       }   
     }
     dm=dd;
     t1+=dt1;
index 121c7ad..9ee597b 100644 (file)
@@ -859,7 +859,9 @@ void AliSplineFit::MakeKnots0(TGraph * graph, Double_t maxdelta, Int_t minpoints
   //
 
   Int_t npoints  = graph->GetN();
-  Double_t *xknots = new Double_t[npoints];
+  Double_t *xknots = new Double_t[npoints]; 
+  for (Int_t ip=0;ip<npoints;ip++) xknots[ip]=0;
+  //
   Int_t nknots =0;
   Int_t ipoints =0;
   //
@@ -971,9 +973,9 @@ void AliSplineFit::Test(Int_t npoints, Int_t ntracks, Float_t snoise){
     Double_t sigmaS = hS->GetRMS();
     char fname[100];
     if (fit.fN<20){
-      sprintf(fname,"pol%d",fit.fN);
+      snprintf(fname,100,"pol%d",fit.fN);
     }else{
-      sprintf(fname,"pol%d",19);
+      snprintf(fname,100,"pol%d",19);
     }
     TF1 fpol("fpol",fname);
     graph1->Fit(&fpol);
index 10ff78c..a8dbc98 100644 (file)
@@ -90,6 +90,7 @@
 
 #include "TTimeStamp.h"
 #include "AliSysInfo.h"
+#include "TBufferFile.h"
 
 //#include "TMemStatManager.h"  //USE IFDEF
 
@@ -336,3 +337,19 @@ TTree*  AliSysInfo::Test(){
   TTree * tree = AliSysInfo::MakeTree("syswatch.log");
   return tree;  
 }
+
+Double_t AliSysInfo::EstimateObjectSize(TObject* object){
+  //
+  // Estimate size of object as represented in the memory size in bytes
+  // Warnings:
+  //  1. Only data memebrs which are persistent are counted
+  //  2. Local copy of the object is temporary created in memory
+  //  3. Do not use it in standard programs, time and memory consument procedure
+  //
+  if (!object) return 0;
+  TBufferFile * file = new TBufferFile(TBuffer::kWrite);
+  file->WriteObject(object);
+  Double_t size=file->Length();
+  delete file;
+  return size;
+}
index ea13fc7..a57ebe8 100644 (file)
@@ -29,6 +29,9 @@ public:
   static Bool_t Contain(const char * str1, const char * str2);
   typedef void (*StampCallback_t)(const Char_t * desription);
   static  void AddCallBack(StampCallback_t callback);
+  //
+  // Object size function
+  static Double_t EstimateObjectSize(TObject* object);
   static  TTree* Test();
 private:
   AliSysInfo(const AliSysInfo& source);
index 0e20133..b2206b2 100644 (file)
@@ -192,7 +192,7 @@ TTreeStream  & TTreeSRedirector::operator<<(Int_t id)
     TDirectory * backup = gDirectory;
     fFile->cd();
     char chname[100];
-    sprintf(chname,"Tree%d",id);
+    snprintf(chname,100,"Tree%d",id);
     clayout = new TTreeStream(chname);
     clayout->fId=id;
     fDataLayouts->AddAt(clayout,entries);
@@ -334,14 +334,14 @@ Int_t TTreeStream::CheckIn(Char_t type, void *pointer)
     char name[1000];
     if (fNextName.Length()>0){
       if (fNextNameCounter==0){
-       sprintf(name,"%s",(const char*)fNextName);
+       snprintf(name,1000,"%s",(const char*)fNextName);
       }
       if (fNextNameCounter>0){
-       sprintf(name,"%s%d",(const char*)fNextName,fNextNameCounter);
+       snprintf(name,1000,"%s%d",(const char*)fNextName,fNextNameCounter);
       }      
     }
     else{
-      sprintf(name,"B%d.",fCurrentIndex);
+      snprintf(name,1000,"B%d.",fCurrentIndex);
     }
     element->SetName(name);
     //
@@ -372,14 +372,14 @@ Int_t TTreeStream::CheckIn(TObject *o){
     char name[1000];
     if (fNextName.Length()>0){
       if (fNextNameCounter==0){
-       sprintf(name,"%s",(const char*)fNextName);
+       snprintf(name,1000,"%s",(const char*)fNextName);
       }
       if (fNextNameCounter>0){
-       sprintf(name,"%s%d",(const char*)fNextName,fNextNameCounter);
+       snprintf(name,1000,"%s%d",(const char*)fNextName,fNextNameCounter);
       }      
     }
     else{
-      sprintf(name,"B%d",fCurrentIndex);
+      snprintf(name,1000,"B%d",fCurrentIndex);
     }
     element->SetName(name);
 
@@ -411,10 +411,10 @@ void TTreeStream::BuildTree(){
     TTreeDataElement* element = (TTreeDataElement*)fElements->At(i);
     char bname1[1000];
     if (element->GetName()[0]==0){
-      sprintf(bname1,"B%d",i);
+      snprintf(bname1,1000,"B%d",i);
     }
     else{
-      sprintf(bname1,element->GetName());
+      snprintf(bname1,1000,element->GetName());
     }
     if (element->fClass){
       if (element->fClass->GetBaseClass("TClonesArray")){
@@ -428,7 +428,7 @@ void TTreeStream::BuildTree(){
     }
     if (element->GetType()>0){
       char bname2[1000];
-      sprintf(bname2,"B%d/%c",i,element->GetType());
+      snprintf(bname2,1000,"B%d/%c",i,element->GetType());
       TBranch * br = fTree->Branch(bname1,element->fPointer,bname2);
       fBranches->AddAt(br,i);
     }