[LIP] Query:tcsetattr on disk file descriptor and free function issue.
Shehjar Tikoo <shehjar_tikoo-/[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
Hi everyone.
I have 2 questions.The second one is a little
longer.So kindly bear with me for a while.
They are below:
1. Can I use the tcXXXattr functions to get and set
the attributes of the file descriptor to ICANON so
that a read on this file descriptor returns only a
single line? Something like what fgets does for
standard io.
2. I have a structure like the one below:
struct pthead {
char path[1024];
....
.... /* Other members */
};
then I do something like this:
struct pthead *head;
Then use malloc to allocate memory.
When I am done using head I use a function that in the
end calls free like.
void freepthead(struct pthead *h) {
.....
....
free(head);
}
From the main I call freepthead and pass it head.
After freepthead returns I am still able to read the
contents of the path member of the structure, contents
which are same as those stored in path before calling
freepthead.
Should'nt the fprintf statement below cause a
segmentation fault:
freepthead(head);
fprintf(stdout,"%s\n",head->path);
That was a long one.But I'll be so grateful to those
who can answer these queries.
Thanks a ton for atleast reading it upto here.
-Shehjar
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn