--- chewbacca/YodaProfiler/src/GLTables.cpp 2009/12/15 10:23:28 1.13 +++ chewbacca/YodaProfiler/src/GLTables.cpp 2011/11/29 13:42:18 1.15 @@ -68,6 +68,8 @@ return NULL; }; // + if (Row) + delete Row; pResult = dbc->Query(query.Data()); // Row = pResult->Next(); @@ -97,6 +99,8 @@ if ( f2 < minf2 ) minf2 = f2; }; + if (Row) + delete Row; Row = pResult->Next(); }; pResult->Delete(); @@ -136,6 +140,8 @@ // pResult = dbc->Query(query.Data()); // + if (Row) + delete Row; Row = pResult->Next(); // Int_t r = 0; @@ -151,6 +157,8 @@ h2->Fill(f1,f2); }; r++; + if (Row) + delete Row; Row = pResult->Next(); }; // @@ -164,6 +172,8 @@ if ( dim == 1 ) h1->Draw(); if ( dim == 2 ) h2->Draw(); // + if (Row) + delete Row; pResult->Delete(); if ( dim == 1 ) return h1; if ( dim == 2 ) return h2; @@ -237,6 +247,7 @@ if ( dbc ){ dbc->Close(); delete dbc; + dbc = 0; }; dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); // @@ -674,7 +685,7 @@ Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){ // MySQL variables TSQLResult *pResult; - TSQLRow *Row; + TSQLRow *Row = NULL; stringstream myquery; // if ( !IDRUN ) IDRUN = ID; @@ -738,6 +749,8 @@ UInt_t idl0 = 0; UInt_t idl2 = 0; // + if (Row) + delete Row; Row = pResult->Next(); if( Row != NULL ){ idtrash = (UInt_t)atoll(Row->GetField(0)); @@ -757,6 +770,8 @@ this->GetGLTABLES()->AddQ(); pResult = dbc->Query(myquery.str().c_str()); // + if (Row) + delete Row; Row = pResult->Next(); if( Row != NULL ){ fileL0 = (TString)Row->GetField(0); @@ -774,10 +789,16 @@ this->GetGLTABLES()->AddQ(); pResult = dbc->Query(myquery.str().c_str()); // + if (Row) + delete Row; Row = pResult->Next(); if( Row != NULL ){ fileL2 = (TString)Row->GetField(0); - }; + } + if (Row){ + delete Row; + Row = NULL; // This variable is not used below + } // // // @@ -842,7 +863,7 @@ //insert into GL_RUN_TRASH VALUES (ID , ID_RUN_FRAG , ID_ROOT_L0 , ID_ROOT_L2 , RUNHEADER_TIME , RUNTRAILER_TIME , RUNHEADER_OBT , RUNTRAILER_OBT , RUNHEADER_PKT , RUNTRAILER_PKT , BOOT_NUMBER , EV_FROM , EV_TO , NEVENTS , PKT_COUNTER , PKT_READY_COUNTER , COMPILATIONTIMESTAMP , FAV_WRK_SCHEDULE , EFF_WRK_SCHEDULE , PRH_VAR_TRG_MODE_A , PRH_VAR_TRG_MODE_B , ACQ_BUILD_INFO , ACQ_VAR_INFO , RM_ACQ_AFTER_CALIB , RM_ACQ_SETTING_MODE, TRK_CALIB_USED,CAL_DSP_MASK, LAST_TIMESYNC, OBT_TIMESYNC, VALIDATION, INSERT_TIME) select * FROM GL_RUN where ID=11; // MySQL variables TSQLResult *pResult; - TSQLRow *Row; + TSQLRow *Row = NULL; stringstream myquery; // if ( !IDRUN ) IDRUN = ID; @@ -1143,8 +1164,7 @@ Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ // MySQL variables TSQLResult *pResult; - TSQLRow *Row; - int t; + TSQLRow *Row = NULL; int r; stringstream myquery; // ---------------- @@ -1193,11 +1213,13 @@ // if( !pResult->GetRowCount() ) return(-50); // - for( r=0; r < 1000; r++){ + for( r=0; r < 1000; r++){ + if (Row) + delete Row; Row = pResult->Next(); if( Row == NULL ) break; // Set_GL_RUN(Row); - for( t = 0; t < pResult->GetFieldCount(); t++){ + for( int t = 0; t < pResult->GetFieldCount(); t++){ if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); @@ -1231,8 +1253,11 @@ if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); }; - }; - // delete pResult; + } + + if (Row) + delete Row; + delete pResult; return(0); }; @@ -1246,7 +1271,7 @@ Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ // MySQL variables TSQLResult *pResult; - TSQLRow *Row; + TSQLRow *Row = NULL; int t; int r; stringstream myquery; @@ -1294,6 +1319,8 @@ pResult = dbc->Query(myquery.str().c_str()); if(!pResult->GetRowCount())return(-50); for( r=0; r < 1000; r++){ + if (Row) + delete Row; Row = pResult->Next(); if( Row == NULL ) break; for( t = 0; t < pResult->GetFieldCount(); t++){ @@ -1330,8 +1357,11 @@ if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); }; - }; - // delete pResult; + } + + if (Row) + delete Row; + delete pResult; return(0); };// **************************************************** @@ -1344,7 +1374,7 @@ Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ // MySQL variables TSQLResult *pResult; - TSQLRow *Row; + TSQLRow *Row = NULL; int t; int r; stringstream myquery; @@ -1363,6 +1393,8 @@ pResult = dbc->Query(myquery.str().c_str()); if(!pResult->GetRowCount())return (-51); for( r=0; r < 1000; r++){ + if (Row) + delete Row; Row = pResult->Next(); if( Row == NULL ) break; for( t = 0; t < pResult->GetFieldCount(); t++){ @@ -1371,8 +1403,10 @@ if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); if(t==3) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/'; if(t==4) NAME = Row->GetField(t); - }; - }; + } + } + if (Row) + delete Row; delete pResult; return 0; }; @@ -1387,7 +1421,7 @@ Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ // MySQL variables TSQLResult *pResult; - TSQLRow *Row; + TSQLRow *Row = NULL; int t; int r; stringstream myquery; @@ -1403,6 +1437,8 @@ pResult = dbc->Query(myquery.str().c_str()); if(!pResult->GetRowCount())return (-53); for( r=0; r < 1000; r++){ + if (Row) + delete Row; Row = pResult->Next(); if( Row == NULL ) break; for( t = 0; t < pResult->GetFieldCount(); t++){ @@ -1423,7 +1459,9 @@ if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); }; - }; + } + if (Row) + delete Row; delete pResult; // // if ( TO_TIME < time ) return(51); @@ -1443,7 +1481,7 @@ Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){ // MySQL variables TSQLResult *pResult; - TSQLRow *Row; + TSQLRow *Row = NULL; int t; stringstream myquery; uptime = 0; @@ -1463,6 +1501,8 @@ // printf(" mysquery is %s\n",myquery.str().c_str()); // if( !pResult->GetRowCount() ) return(-54); + if (Row) + delete Row; Row = pResult->Next(); if( Row == NULL ) return (-54); // @@ -1490,6 +1530,8 @@ // if( !pResult->GetRowCount() ) return (-54); // + if (Row) + delete Row; Row = pResult->Next(); // myfromtime = (UInt_t)atoll(Row->GetField(1)); @@ -1512,6 +1554,8 @@ // if( !pResult->GetRowCount() ) return (-54); // + if (Row) + delete Row; Row = pResult->Next(); // }; @@ -1524,7 +1568,9 @@ if (t==1) FROM_TIME = myfromtime; if (t==2) TO_TIME = mytotime; if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); - }; + } + if (Row) + delete Row; pResult->Delete(); return 0; }; @@ -1540,7 +1586,7 @@ Int_t GL_CALOPULSE_CALIB::Query_GL_CALOPULSE_CALIB(UInt_t time, UInt_t section, UInt_t pampli, TSQLServer *dbc){ // MySQL variables TSQLResult *pResult; - TSQLRow *Row; + TSQLRow *Row = NULL; int t; stringstream myquery; // @@ -1558,6 +1604,8 @@ // if( !pResult ) return(-54); // + if (Row) + delete Row; Row = pResult->Next(); // if( !Row ) return (-54); @@ -1570,7 +1618,9 @@ if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); - }; + } + if (Row) + delete Row; pResult->Delete(); return 0; }; @@ -1586,7 +1636,7 @@ Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){ // MySQL variables TSQLResult *pResult; - TSQLRow *Row; + TSQLRow *Row = NULL; int t; int r; stringstream myquery; @@ -1600,6 +1650,8 @@ pResult = dbc->Query(myquery.str().c_str()); if(!pResult->GetRowCount())return (-55);//throw -55; for( r=0; r < 1000; r++){ + if (Row) + delete Row; Row = pResult->Next(); if( Row == NULL ) break; for( t = 0; t < pResult->GetFieldCount(); t++){ @@ -1609,7 +1661,9 @@ if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); }; - }; + } + if (Row) + delete Row; delete pResult; // if(TO_TIME < time)return(51); @@ -1628,7 +1682,7 @@ // Bool_t debug = 1; // MySQL variables TSQLResult *pResult; - TSQLRow *Row; + TSQLRow *Row = NULL; int t; int r; stringstream myquery; @@ -1646,6 +1700,8 @@ pResult = dbc->Query(myquery.str().c_str()); if(!pResult->GetRowCount())return (-52); for( r=0; r < 1000; r++){ + if (Row) + delete Row; Row = pResult->Next(); if( Row == NULL ) break; for( t = 0; t < pResult->GetFieldCount(); t++){ @@ -1657,7 +1713,9 @@ if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); }; - }; + } + if (Row) + delete Row; delete pResult; // if(TO_TIME==0) TO_TIME = numeric_limits::max(); @@ -1693,7 +1751,7 @@ UInt_t idtsy = 0; // TSQLResult *pResult; - TSQLRow *Row = 0; + TSQLRow *Row = NULL; stringstream myquery; stringstream rname; // pcksList packetsNames; @@ -1713,6 +1771,8 @@ this->GetGLTABLES()->AddQ(); pResult = dbc->Query(myquery.str().c_str()); if( pResult->GetRowCount() ){ + if (Row) + delete Row; Row = pResult->Next(); if( Row ){ stringstream fname; @@ -1757,6 +1817,8 @@ pResult = dbc->Query(oss.str().c_str()); Bool_t fndit = false; if ( pResult ){ + if (Row) + delete Row; Row = pResult->Next(); if ( Row ){ // @@ -1772,13 +1834,15 @@ this->GetGLTABLES()->AddQ(); delete pResult; pResult = dbc->Query(oss.str().c_str()); - if ( pResult ){ - Row = pResult->Next(); - if ( Row ){ - // printf(" GREAT! the DB structure is the new one! \n"); - fndit = true; - dworbit = 1; - }; + if (pResult){ + if (Row) + delete Row; + Row = pResult->Next(); + if ( Row ){ + // printf(" GREAT! the DB structure is the new one! \n"); + fndit = true; + dworbit = 1; + }; }; }; }; @@ -1797,6 +1861,8 @@ // printf(" T0 %u toffset is %u \n",T0,toffset); // if ( file ) file->Close(); + if (Row) + delete Row; delete pResult; }; @@ -1806,7 +1872,7 @@ UInt_t idtsy = 0; // TSQLResult *pResult; - TSQLRow *Row = 0; + TSQLRow *Row = NULL; stringstream myquery; stringstream rname; // pcksList packetsNames; @@ -1826,6 +1892,8 @@ this->GetGLTABLES()->AddQ(); pResult = dbc->Query(myquery.str().c_str()); if( pResult->GetRowCount() ){ + if (Row) + delete Row; Row = pResult->Next(); if( Row ){ stringstream fname; @@ -1871,6 +1939,8 @@ pResult = dbc->Query(oss.str().c_str()); Bool_t fndit = false; if ( pResult ){ + if (Row) + delete Row; Row = pResult->Next(); if ( Row ){ // @@ -1886,13 +1956,15 @@ this->GetGLTABLES()->AddQ(); delete pResult; pResult = dbc->Query(oss.str().c_str()); - if ( pResult ){ - Row = pResult->Next(); - if ( Row ){ - // printf(" GREAT! the DB structure is the new one! \n"); - fndit = true; - dworbit = 1; - }; + if (pResult){ + if (Row) + delete Row; + Row = pResult->Next(); + if (Row){ + // printf(" GREAT! the DB structure is the new one! \n"); + fndit = true; + dworbit = 1; + }; }; }; }; @@ -1911,6 +1983,8 @@ // printf(" T0 %u toffset is %u \n",T0,toffset); // if ( file ) file->Close(); + if (Row) + delete Row; delete pResult; }; @@ -2181,7 +2255,7 @@ // Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ TSQLResult *result; - TSQLRow *row; + TSQLRow *row = NULL; // Set the right time_zone (otherwise horrible things will occur! :) if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; @@ -2200,7 +2274,8 @@ tle = GiveTle(row); tleFromTime = strtol(row->GetField(4), NULL, 10); - + if (row) + delete row; row = result->Next(); // second tle row if(row) tleToTime = strtol(row->GetField(4), NULL, 10); @@ -2209,7 +2284,8 @@ tleToTime = UINT_MAX; } - delete row; + if (row) + delete row; delete result; return 0;