I'm not so good at this so apologies for any obvious mistakes.
My problem consists of two functions of a wider algorithm. To simplify I will call them U and S. In a "for" loop, I use U conditionally (using if) and S two times each for each round (I will call them U1, U2, S1 and S2). U1 and U2 comes before S1 and S2. Both functions have variables created and deleted inside the function according to dynamic memory principles.
The problem occurs after some progress in the loop. During that period S1 and S2 work seamlessly and U1 and U2 don't work at all because conditions did not apply yet. Then, U1 and U2 kick in, still no problem, S1 kick in, still no problem they all pass, but S2 fails. The failure occurs at the deletion of an array. There are other arrays in the function and they do not fail at all.
The interesting point is I can delay this failure by simply introducing a dummy string function (see below). Though after the second time the U functions' occurence, my S2 fails again.
1 2 3 4 5 6
|
string ABC(){
return "a";
}
|
S1 and S2 are the same function working on different variables/arrays of the same type, as U1 and U2. U1 and S1 work on the same variables/arrays.
How can I overcome this obstacle? Any ideas?
I can provide the code snippets if you like, but I doubt it would help.