Re: xmalloc string functions
- From: Randy Howard <randyhoward@xxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Jan 2008 08:34:45 GMT
On Tue, 29 Jan 2008 02:12:51 -0600, ymuntyan@xxxxxxxxx wrote
(in article
<a39e790e-bd73-44a2-8ab1-17a8299a2dae@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>):
So, you work with a list, and you append an element to it.
Now you do list = g_list_append(list, something); with malloc
error handling you'll have to test whether list_append()
succeeded. Not much more typing, no. A little bit more, huh?
C++ exceptions would be appropriate here, but manual error
checking in C code *is* much much more typing.
No, it's way better if the guy happens to have a dozen apps open at the
moment, and this one is really critical work that he's been entering
data into for the last 2 hours. You could do this:
Display a message to the effect of "Unable to add new record due to an
out of memory condition, please close some other applications if you
would like to try again, or save the work in progress to prevent data
loss"
BS. You can't display message if you don't have memory. You could
reserve some, specially for the message, and *try* to display it.
But it won't show up anyway.
Sigh. A malloc() failure does not necessarily mean that you are out
of memory in the entire system, or even in your own process. It means
that a specific call to malloc() failed. It's strange that you say
this is "BS", when I have seen these sorts of messages appear on
terminals and displays periodically in various applications over the
last 30 years. Maybe they used magic fairy dust.
But instead, this /wonderfully/ designed application aborts and dumps
all his work.
It's not necessary to dump the user's work. On the contrary,
you should try to save his work if you can. But I'll be glad
to see what you would do in a dictionary application.
Are you claiming that no dictionary application offers any recovery for
a malloc() failure than an abort? If not, what are you trying to say?
If you believe that an mp3 player shouldn't
abort when it can't allocate memory for a playlist, it's a
fine opinion, and you simply shouldn't use mp3 players
based on glib.
On that we can agree.
Others still will (you know why? because it won't abort)
I can't parse this with any degree of confidence.
At any rate, it seems fairly clear that neither of us is going to move
the other, so it seems pointless to continue.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw
.
- References:
- xmalloc string functions
- From: Malcolm McLean
- Re: xmalloc string functions
- From: Yevgen Muntyan
- Re: xmalloc string functions
- From: William Ahern
- Re: xmalloc string functions
- From: Yevgen Muntyan
- Re: xmalloc string functions
- From: William Ahern
- Re: xmalloc string functions
- From: Yevgen Muntyan
- Re: xmalloc string functions
- From: William Ahern
- Re: xmalloc string functions
- From: Yevgen Muntyan
- Re: xmalloc string functions
- From: William Ahern
- Re: xmalloc string functions
- From: Yevgen Muntyan
- Re: xmalloc string functions
- From: Flash Gordon
- Re: xmalloc string functions
- From: ymuntyan
- Re: xmalloc string functions
- From: Randy Howard
- Re: xmalloc string functions
- From: ymuntyan
- xmalloc string functions
- Prev by Date: Re: Fopen to create a file in a sub-folder (such as "Mygoal").
- Next by Date: Re: xmalloc string functions
- Previous by thread: Re: xmalloc string functions
- Next by thread: Re: xmalloc string functions
- Index(es):
Relevant Pages
|