Re: malloc()/realloc() - have I got this right?
- From: "Joachim Schmitz" <nospam.jojo@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 31 May 2008 11:04:08 +0200
santosh wrote:
Joachim Schmitz wrote:s/has/may have/
Antoninus Twink wrote:
On 30 May 2008 at 21:53, CBFalconer wrote:For some reason that is beound me you elected to ignore CBF's next
Ridiculous. Most use of the function simply runs until a non-zero
is returned, after which the operation ends. It may be because of
EOF, or because of error. In either case, no further input is
available.
If you're in a restaurant and can't get your meal either because
they've run out of salmon or because the kitchen's on fire, you
might find it useful to be able to distinguish between those two
error conditions.
sentence, which addresses exaclty that:
If there is a need to distinguish EOF from errors, it
can be done at that point.
The debate was whether the caller or the callee should disambiguate
between end-of-file and error. IMHO doing it in the caller saves a
small amount of otherwise extra work in the calling code, which is
after all, the main purpose of library code. It's unclear from the
above sentence by CBFalconer whether he means the caller or the callee
when he says "at that point". One might assume from the general tone
of his reply and the use of the word "ridiculous" that he prefers
this to be done by the calling code. Either way is fine but I
personally prefer to have the line reading function do this low-level
chore.
In you analogy: just ask the waiter for the reason or listen to the
fire alarm.
The analogy is flawed. The client (line reading function) has to
report the reason to someone else, (perhaps someone at his home). SoEither is fine and at the discretion of the client (customer).
should the client ask the waiter for the reason and go home and
report that, or go home and simply say "the salmon was unavailable"
and leave it to that person to go to the restaurant and ask the
waiter for the reason why Salmon was not available?
If someone else (at home) needs to know and the client didn't bother to ask,
that someone else better uses a different client next time.
Bye, Jojo
.
- Follow-Ups:
- Re: malloc()/realloc() - have I got this right?
- From: santosh
- Re: malloc()/realloc() - have I got this right?
- From: Joachim Schmitz
- 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
- Re: malloc()/realloc() - have I got this right?
- From: Keith Thompson
- Re: malloc()/realloc() - have I got this right?
- From: santosh
- Re: malloc()/realloc() - have I got this right?
- From: CBFalconer
- Re: malloc()/realloc() - have I got this right?
- From: Antoninus Twink
- Re: malloc()/realloc() - have I got this right?
- From: Joachim Schmitz
- Re: malloc()/realloc() - have I got this right?
- From: santosh
- malloc()/realloc() - have I got this right?
- Prev by Date: Re: calling function in C
- Next by Date: Re: Expanding buffer - response to "Determine the size of malloc" query
- 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
|