Re: A89: fwrite function
[Prev][Next][Index][Thread]
Re: A89: fwrite function
I understand that... btw, I tried replying to this sooner, but my smtp
server died. Anyways, a recrusive call to fputc is really wasteful when
we know how much memory we need and can do a straight memcpy from buffer
to file.
Zeljko Juric wrote:
> Scott, I don't understand something (or you don't understand
> something, or maybe both of us). Yes, __fwrite really does
> not any memory checking, but if uses a pointer to function
> (named fnc) which does actual storing a byte into the file.
> If this function is implemented properly (with memory checking
> and reallocating when necessary), everything will be good.
> Now, look the implementation of fwrite later in stdio.h. It
> calls __fwrite passing putc to it as the first argument. In
> fact, it principally does
>
> #define fwrite(p,s,n,f) __fwrite(fputc,p,s,n,f)
>
> except __fwrite is constructed using a cast constructor. As
> fwrite calls fputc (using a fnc parameter), and as fputc uses
> memory checking and reallocating when necessary, fwrite will
> work as expected. So, you are not right about incorrectness
> of implementation of fwrite and fputs. Anyway, I am looking
> for what is wrong with Michael's example.
>
> Cheers,
>
> Zeljko Juric
>
--
Scott "Wrath" Dial
wrath@calc.org
ICQ#3608935
Member of TCPA - tcpa.calc.org
PGP key available
_____NetZero Free Internet Access and Email______
http://www.netzero.net/download/index.html
References: