Hi
I have a problem. I am working on a code that has been poorly maintained . What i need is to use one function from the code to get some value which is then needed for some other computations. Example:
Code:
typdef struct ScoreKey{
...
}ScoreKey;
int main(){
ScoreKey * sc;
FillScKey(sc);
value = UseBlackBoxFunc(sc);
Compute(sc,value);
return 0;
}
As you can see i need to pass a struct to UseBlackBoxFunc() function.
The problem is that, the function UseBlackBoxFunc(sc) changes some of the variables(values) of sc struct, so sc before and after using UseBlackBoxFunc() function is not the same. However i need it to be for Compute() func.
These functions are very complicated and hard to read. Moreover struct's that are send around are also complicated(example):
Code:
typedef struct BlScBlk {
Boolean alphabet;
Uint1 code;
Int2 size;
Int2 start;
char* name;
LiNode* comments;
SBlScMtx* matrix;
SPBlScMtx* Mmatrix;
Int4 losc;
Int4 hisc;
BlScFreq** ftp;
BlKBlk **gbt_std,
**gbt_p,
**gbt_gap_tmp,
**gbt_gap_ps;
Int4 number_of_contexts;
Uint1* ambiguous_res;
Int2 ambig_size,
ambig_occupy;
Boolean round_down;
} ScoreKey;
NO comments or anything and there are at leas 9-10 of those that need to be passed to a function. So instead loosing a year of trying to decipher everything, i was thinking maybe there is a better solution to my problem, like this one:
Code:
typdef struct ScoreKey{
...
}ScoreKey;
int main(){
ScoreKey * sc;
FillScKey(sc);
sc_tmp = MakeCopy(sc);
value = UseBlackBoxFunc(sc_tmp);
Destruct(sc_tmp);
Compute(sc,value);
return 0;
}
Make a copy. Send a copy to BlackBox func. Destroy a copy. Is something like this possible on such complicated structures?? And if yes how?
Is there a better solution ??
Thank you
baxy