[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [leafnode-list] fetchnews fails to download bodies
Stefan Wiens wrote:
> BTW, I just noticed that the [fm]?getheader() functions return newly
> allocated memory. Most functions calling them don't free() the
> returned string, leaking memory.
I fixed this now in most of the functions. I have not fixed anything
so far in fetchnews, mostly because I have a coding question first:
If an fopen() is performed successfully on a file, does this affect
the atime and mtime of the file? I ask because of this piece of
code (from postarticles()):
if ( ( stat( de->d_name, &st ) == 0 ) && S_ISREG( st.st_mode ) &&
( ( f = fopen( de->d_name, "r" ) ) != NULL ) &&
isgrouponserver( fgetheader( f, "Newsgroups:" ) ) &&
( ( haveid =
ismsgidonserver( fgetheader( f, "Message-ID:" ) ) ) != 1 ) ) {
a) Wouldn't it be more efficient to open the file first and then doing
fstat()? There shouldn't be any non-regular files in out.going anyway,
therefore the S_ISREG may be unnecessary (I think it was introduced
because some people managed to create directories in out.going and
complained afterwards about a barfing fetchnews).
b) Obviously, in the code above the strings returned by fgetheader()
cannot be free()d - or is there a possibility that I may have
overlooked?
And another C question (regarding the recent mail by Matthias Andree about
syntax):
c) Can this code
return ( havepath && havemsgid && havefrom && haveng );
also be written without the brackets, i.e. is it ensured that
the logical expression will be evaluated first and the result
being returned?
--Cornelius.
--
/* Cornelius Krasel, U Wuerzburg, Dept. of Pharmacology, Versbacher Str. 9 */
/* D-97078 Wuerzburg, Germany email: krasel@xxxxxxxxxxxxxxxxxxxxxxxxxxxx */
/* "Science is the game we play with God to find out what His rules are." */
--
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list