Index: SigProc/trunk/SigProc/fec_conv.cpp
===================================================================
--- SigProc/trunk/SigProc/fec_conv.cpp	(revision 4184)
+++ SigProc/trunk/SigProc/fec_conv.cpp	(revision 4187)
@@ -228,5 +228,5 @@
     if (theTrellis!=NULL){
         for (unsigned int i = 0; i < theTrellisTable->numberOfTrellisStates; i++){
-            delete theTrellis[i];
+            delete []theTrellis[i];
         };
         
@@ -255,28 +255,33 @@
 void fec_conv_decoder::SetNoOfSymbols2TraceBack(unsigned int traceBackLength){
     //std::cout<<theTrellis;
-    if (theTrellis!=NULL){
+
+    if (fec_conv_decoder::noOfSymbols2TraceBack!=traceBackLength){
+         fec_conv_decoder::noOfSymbols2TraceBack=traceBackLength;
+        if (theTrellis!=NULL){
+            for (unsigned int i = 0; i < theTrellisTable->numberOfTrellisStates; i++){
+                delete []theTrellis[i];
+            };
+            delete []theTrellis;
+            theTrellis=NULL;
+        }
+        //std::cout<<theTrellis;
+        //int dummy;
+        //std::cin>>dummy;
+
+    
+
+        theTrellis= new TrellisEntry*[theTrellisTable->numberOfTrellisStates];
         for (unsigned int i = 0; i < theTrellisTable->numberOfTrellisStates; i++){
-            delete theTrellis[i];
+         theTrellis[i] =new TrellisEntry[noOfSymbols2TraceBack+1];
         };
-        delete []theTrellis;
-        theTrellis=NULL;
-    }
-    //std::cout<<theTrellis;
-    //int dummy;
-    //std::cin>>dummy;
-
-    fec_conv_decoder::noOfSymbols2TraceBack=traceBackLength;
-
-    theTrellis= new TrellisEntry*[theTrellisTable->numberOfTrellisStates];
-    for (unsigned int i = 0; i < theTrellisTable->numberOfTrellisStates; i++){
-        theTrellis[i] =new TrellisEntry[noOfSymbols2TraceBack+1];
-    };
-
-    if (tracedBackSymbols!=NULL){
-        delete []tracedBackSymbols;
-        tracedBackSymbols=NULL;
-    };
+
+        if (tracedBackSymbols!=NULL){
+            delete []tracedBackSymbols;
+            tracedBackSymbols=NULL;
+        };
     tracedBackSymbols = new unsigned int [noOfSymbols2TraceBack];
 
+    }
+/*
     currentTrellisIndex=0;
     for (unsigned int i=0;i<theTrellisTable->numberOfTrellisStates;i++)
@@ -287,5 +292,6 @@
         }
     theTrellis[0][0].distance=0;
-
+*/
+    fec_conv_decoder::Reset();
 }
 
@@ -297,5 +303,5 @@
     signed int distance;
 
-    inbits=0;
+   // inbits=0;
     for (unsigned short int i=0;i<theTrellisTable->n;i++){
         tmp=inputData[i];
@@ -315,7 +321,8 @@
     };
 
-     if (inbits>(unsigned int)(pow(theTrellisTable->n,2)-1)){
+     if (inbits>(unsigned int)(pow(2.0,(float)theTrellisTable->n)-1)){
         std::cout<<"ERROR:fec_conv_decoder::Symbol2Decode inbits>2^n-1\n";
-        std::cout<<"inbits:"<<inbits<<" numberOfInputStates:"<<pow(theTrellisTable->n,2)-1;
+        std::cout<<"inbits:"<<inbits<<"   2^n-1: "<<(unsigned int)pow(2.0,(float)theTrellisTable->n)-1
+            <<"n="<<theTrellisTable->n<<"\n";
         throw 0;
     };
