From 2c8d923f05799db1e25c38aa752d901c107cbe5e Mon Sep 17 00:00:00 2001 From: Steffen Moeller Date: Sun, 21 Apr 2024 17:15:53 +0200 Subject: [PATCH 1/3] Optics: TSilmutDialog (indent) and TPrimer (declaration) --- src/TPrimer.cpp | 5 ++--- src/TSilmutDialog.cpp | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/TPrimer.cpp b/src/TPrimer.cpp index 35c0dbe1..bf20bb87 100644 --- a/src/TPrimer.cpp +++ b/src/TPrimer.cpp @@ -236,9 +236,8 @@ void TPrimer::OligoCount () /* not const */ for ( int i = 1 ; i < seq.length() ; i++ ) //first base can not be IUpacbase { - wxString base , base0 ; - base0 += seq.GetChar(i-1) ; - base += seq.GetChar(i) ; + wxString base0 = seq.GetChar(i-1) ; + wxString base = seq.GetChar(i) ; double *temp ; temp=CalcIUpair(base0, base, i, false ); diff --git a/src/TSilmutDialog.cpp b/src/TSilmutDialog.cpp index 63f0ec5f..60ca6e52 100644 --- a/src/TSilmutDialog.cpp +++ b/src/TSilmutDialog.cpp @@ -178,8 +178,8 @@ void TSilmutDialog::OnCancel ( wxCommandEvent &ev ) void TSilmutDialog::OnSpin ( wxSpinEvent &event ) { - wxCommandEvent event2 ; - OnSpin2 ( event2 ) ; + wxCommandEvent event2 ; + OnSpin2 ( event2 ) ; } void TSilmutDialog::OnSpin2 ( wxCommandEvent &event ) From bf10a7237398354b4676dbf9d63df397db626c92 Mon Sep 17 00:00:00 2001 From: Steffen Moeller Date: Sun, 21 Apr 2024 17:17:10 +0200 Subject: [PATCH 2/3] checking memory allocation while drawing --- src/PlasmidCanvasLinear.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PlasmidCanvasLinear.cpp b/src/PlasmidCanvasLinear.cpp index 3ef90d18..cb75dbe3 100644 --- a/src/PlasmidCanvasLinear.cpp +++ b/src/PlasmidCanvasLinear.cpp @@ -356,6 +356,11 @@ void PlasmidCanvas::drawLinearItem ( wxDC& dc , const int _r1 , const int _r2 , // Drawing polygon wxPoint *wp ; wp = (wxPoint*) malloc ( sizeof ( wxPoint ) * (pt.size()+1) ) ; + if (!wp) + { + wxPrintf("E: Out of memory.\n") ; + abort() ; + } for ( unsigned int b = 0 ; b < pt.size() ; b++ ) wp[b] = pt[b] ; if ( !this->p->vec->getGenomeMode() ) dc.SetPen(*wxBLACK_PEN); else dc.SetPen ( *MYPEN((wxColour)i->getBrush()->GetColour()) ) ; From b6d132c98be82fe12ed82005861f80d9f226fb6d Mon Sep 17 00:00:00 2001 From: Steffen Moeller Date: Sun, 21 Apr 2024 17:39:56 +0200 Subject: [PATCH 3/3] optics: diverse --- src/TIMGreader.cpp | 10 ++++----- src/TIMGreader.h | 4 ++-- src/TLigationDialog.cpp | 45 ++++++++++++++++++++--------------------- src/TLigationDialog.h | 2 +- src/ureadseq.c | 9 ++++++--- src/ureadseq.h | 3 +-- 6 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/TIMGreader.cpp b/src/TIMGreader.cpp index dd6fc0f7..1f360837 100644 --- a/src/TIMGreader.cpp +++ b/src/TIMGreader.cpp @@ -9,12 +9,12 @@ TIMGreader::~TIMGreader () if ( buffer ) { delete buffer ; - buffer = NULL ; + buffer = NULL ; } if ( output ) { - free( output ) ; - output = NULL ; + free( output ) ; + output = NULL ; } } @@ -134,12 +134,12 @@ void TIMGitem::draw ( wxDC &dc , int x1 , int y1 , int x2 , int y2 ) } } -int TIMGitem::xx ( int x ) +int TIMGitem::xx ( const int x ) const { return off.x + x * 19 / 24 ; } -int TIMGitem::yy ( int y ) +int TIMGitem::yy ( const int y ) const { return off.y + y * 9 / 12 ; } diff --git a/src/TIMGreader.h b/src/TIMGreader.h index 25894fdc..7627ff7c 100644 --- a/src/TIMGreader.h +++ b/src/TIMGreader.h @@ -14,8 +14,8 @@ class TIMGitem { public : void draw ( wxDC &dc , int x1 , int y1 , int x2 , int y2 ) ; ///< Draws the annotation - int xx ( int x ) ; ///< X-coordinate conversion - int yy ( int y ) ; ///< Y-coordinate conversion + int xx ( const int x ) const ; ///< X-coordinate conversion + int yy ( const int y ) const ; ///< Y-coordinate conversion int type ; ///< Annotation type wxPoint p1 , p2 ; diff --git a/src/TLigationDialog.cpp b/src/TLigationDialog.cpp index 13db1d79..59d31dd5 100644 --- a/src/TLigationDialog.cpp +++ b/src/TLigationDialog.cpp @@ -87,7 +87,7 @@ void TLigationDialog::init () { bool state = true ; if ( !vv[a]->hasStickyEnds() ) - state = false ; // blunt ends are not ligated by default... + state = false ; // blunt ends are not ligated by default... l_sources->Append ( vv[a]->getName() ) ; l_sources->Check ( a , state ) ; } @@ -98,11 +98,10 @@ void TLigationDialog::init () void TLigationDialog::generateTargets () { - int a ; int cnt = l_sources->GetCount() ; vector vc , used ; wxArrayInt vi ; - for ( a = 0 ; a < cnt ; a++ ) + for ( int a = 0 ; a < cnt ; a++ ) { vc.push_back ( l_sources->IsChecked ( a ) ) ; used.push_back ( !l_sources->IsChecked ( a ) ) ; @@ -113,7 +112,7 @@ void TLigationDialog::generateTargets () l_targets->Clear () ; // Using each selected item as a starter - for ( a = 0 ; a < cnt ; a++ ) + for ( int a = 0 ; a < cnt ; a++ ) { if ( vc[a] ) { @@ -129,7 +128,7 @@ void TLigationDialog::generateTargets () } } - for ( a = 0 ; a < vt.GetCount() ; a++ ) + for ( int a = 0 ; a < vt.GetCount() ; a++ ) { l_targets->Append ( vt[a] ) ; l_targets->Check ( a , true ) ; @@ -191,15 +190,15 @@ void TLigationDialog::curseTargets ( vector &vc , vector &used , w myass ( a >= 0 && a < vc.size() , "TLigationDialog::curseTargets:4b" ) ; myass ( a >= 0 && a < used.size() , "TLigationDialog::curseTargets:4c" ) ; if ( vc[a] && !used[a] && doMatch ( vi[cnt-1] , a , true ) ) // Turned around - { - used[a] = true ; - vi.Add ( a ) ; - orientation.push_back ( true ) ; - curseTargets ( vc , used , vi ) ; - orientation.pop_back () ; - vi.RemoveAt ( vi.GetCount() - 1 ) ; - used[a] = false ; - } + { + used[a] = true ; + vi.Add ( a ) ; + orientation.push_back ( true ) ; + curseTargets ( vc , used , vi ) ; + orientation.pop_back () ; + vi.RemoveAt ( vi.GetCount() - 1 ) ; + used[a] = false ; + } } } @@ -210,7 +209,7 @@ wxString TLigationDialog::invert ( const wxString& s ) const return t ; } -bool TLigationDialog::doMatch ( int l , int r , bool invertSecond ) +bool TLigationDialog::doMatch ( const int& l , const int& r , const bool& invertSecond ) const { wxString s1 , s2 ; @@ -219,15 +218,15 @@ bool TLigationDialog::doMatch ( int l , int r , bool invertSecond ) myass ( r >= 0 && r < vv.GetCount() , "TLigationDialog::doMatch:3" ) ; myass ( vv[r] , "TLigationDialog::doMatch:4" ) ; if ( invertSecond ) - { - s1 = vv[l]->getStickyEnd(false,true) + invert ( vv[r]->getStickyEnd(false,false) ) ; - s2 = vv[l]->getStickyEnd(false,false) + invert ( vv[r]->getStickyEnd(false,true) ) ; - } + { + s1 = vv[l]->getStickyEnd(false,true) + invert ( vv[r]->getStickyEnd(false,false) ) ; + s2 = vv[l]->getStickyEnd(false,false) + invert ( vv[r]->getStickyEnd(false,true) ) ; + } else - { - s1 = vv[l]->getStickyEnd(false,true) + vv[r]->getStickyEnd(true,true) ; - s2 = vv[l]->getStickyEnd(false,false) + vv[r]->getStickyEnd(true,false) ; - } + { + s1 = vv[l]->getStickyEnd(false,true) + vv[r]->getStickyEnd(true,true) ; + s2 = vv[l]->getStickyEnd(false,false) + vv[r]->getStickyEnd(true,false) ; + } TVector v ; v.setSequence ( s1 ) ; diff --git a/src/TLigationDialog.h b/src/TLigationDialog.h index 3e60f3d2..a53e39bd 100644 --- a/src/TLigationDialog.h +++ b/src/TLigationDialog.h @@ -25,7 +25,7 @@ class TLigationDialog : public wxDialog virtual void init () ; ///< Initialize virtual void generateTargets () ; ///< Generate the target list virtual void curseTargets ( vector &vc , vector &used , wxArrayInt &vi ) ; ///< Recurse through targets - virtual bool doMatch ( int l , int r , bool invertSecond = false ) ; ///< Do these match? + virtual bool doMatch ( const int& l , const int& r , const bool& invertSecond = false ) const ; ///< Do these match? virtual wxString getVIName ( const wxArrayInt &vi ) const ; ///< Generate a name virtual void addVTname ( const wxString& name , wxArrayInt &vi , const bool circular ) ; ///< Add this one diff --git a/src/ureadseq.c b/src/ureadseq.c index eb4be48b..e84d50ee 100644 --- a/src/ureadseq.c +++ b/src/ureadseq.c @@ -1124,7 +1124,7 @@ char *readSeq( char *listSeqs( - const char *filename_, /* file name */ + const char * const filename_, /* file name */ const size_t skiplines_, const short format_, /* sequence file format */ size_t *nseq_, /* number of seqs in file, for listSeqs() */ @@ -1345,17 +1345,18 @@ short seqFileFormatFp( if (format == kPhylip) { /* check for interleaved or sequential -- really messy */ int tname, tseq; - size_t i, j, nspp= 0, nlen= 0, ilen, leaf= 0, seq= 0; + size_t j, nspp= 0, nlen= 0, ilen, leaf= 0, seq= 0; char *ps; rewind(fseq); - for (i=0; i < *skiplines; i++) ReadOneLine(sp); + for (size_t i=0; i < *skiplines; i++) ReadOneLine(sp); nlines= 0; ReadOneLine(sp); sscanf( sp, "%ld%ld", &nspp, &nlen); ReadOneLine(sp); /* 1st seq line */ for (ps= sp+10, ilen=0; *ps!=0; ps++) if (isprint(*ps)) ilen++; + size_t i; for (i= 1; i