Nimesh Srivastava Beginner

Joined: 22 Jul 2003 Posts: 13 Topics: 8
|
Posted: Thu Nov 18, 2004 3:09 am Post subject: Recognizing fopen in a function call |
|
|
Hi,
We are currently facing a problem ( an existing system with lots of fopen in functions and missing fclose at all exit conditions of those functions).
Is there a way I can recognize the number of files opened within a function, so that an inline RETURN function would close all the file handles opened only within that function.
For ex.
main()
{
funcA();
funcB();
}
funcA()
{
...
fp1 = fopen("DD:abc1",Mode);
fp2 = fopen("DD:abc2",Mode);
...
RETURN(4); // failure return would close only fp1 & fp2
...
RETURN(0); // new inline function would close only fp1 & fp2
}
funcB()
{
...
fp3 = fopen("DD:xyz1",Mode);
fp4 = fopen("DD:xyz2",Mode);
...
...
RETURN(0); // new inline function would close only fp3 & fp4
}
inline int RETURN(int a)
{
// recognize all open handles in that module
// close them one by one
return success
}
Or if any other solution can be suggested...
Thanks,
Nimesh |
|