Re: malloc()/realloc() - have I got this right?
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 30 May 2008 09:31:08 -0700
Richard Heathfield <rjh@xxxxxxxxxxxxxxx> writes:
CBFalconer said:
Richard Heathfield wrote:
CBFalconer said:... snip ...
enum {OK = 0, NOMEM};
Are those the only two failure conditions? What about end of file?
Or a stream error? Why not make it possible to report those?
You didn't read the whole routine. It also returns EOF, which is
not defined here. I did point out that this listing omitted the
documentation etc.
Your point is well-taken, although it does seem that you fail to
distinguish between genuine end-of-file and a stream error.
So does fgets(). That's what feof() and ferror() are for.
[snip]
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: malloc()/realloc() - have I got this right?
- From: santosh
- Re: malloc()/realloc() - have I got this right?
- From: Richard Heathfield
- Re: malloc()/realloc() - have I got this right?
- References:
- malloc()/realloc() - have I got this right?
- From: Dave
- Re: malloc()/realloc() - have I got this right?
- From: CBFalconer
- Re: malloc()/realloc() - have I got this right?
- From: Richard Heathfield
- Re: malloc()/realloc() - have I got this right?
- From: CBFalconer
- Re: malloc()/realloc() - have I got this right?
- From: Richard Heathfield
- Re: malloc()/realloc() - have I got this right?
- From: CBFalconer
- Re: malloc()/realloc() - have I got this right?
- From: Richard Heathfield
- malloc()/realloc() - have I got this right?
- Prev by Date: Re: replace substring
- Next by Date: Re: printing error messages
- Previous by thread: Re: malloc()/realloc() - have I got this right?
- Next by thread: Re: malloc()/realloc() - have I got this right?
- Index(es):
Relevant Pages
|