fdopen , open and memory release within scope ...
R. Kannan
kannan at cathedral.cerc.wvu.wvnet.edu
Tue May 8 07:41:25 AEST 1990
---======================
PSEUDO CODE
---======================
fn2(x)
int x ;
{
FILE *fx , *fopen ;
fx = fdopen (x,.... ); /* memory gets allocated */
/* want to free the memory without closing the file descriptor
so that file descriptor can be used in the caller's scope
and close within that scope
*/
fclose (fx ) ; /* WILL CLOSE THE FILE associated withe
the input parameter as well isnt it?
/* rest of fn2 */
}
fn1()
{
int x ;
x= open ( filename, mode etc );
fn2(x) ;
/* want to do other things as well as close the x */
}
---======
PROBLEM::
I want to do pass a file descriptor to a function wherein
the function converts the file descriptor to a FILE pointer
using fdopen.
Now on exiting from the function I want to free all memories
allocated (because of the FILE poitner) and leave the file
descriptor in tact.
Could you please e-mail to me if you have any sugestions.
Please do E-MAIL. Prefer e-mail than posting to the whole
net. Will summarize if there are requests ....
--kannan
More information about the Comp.unix.questions
mailing list