[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [llnl-devel] Re: [Freeipmi-devel] xmalloc
From: |
Jim Garlick |
Subject: |
Re: [llnl-devel] Re: [Freeipmi-devel] xmalloc |
Date: |
Tue, 30 Dec 2003 16:30:57 -0800 (PST) |
On Tue, 30 Dec 2003, Anand Babu wrote:
> ,----[ Albert Chu <address@hidden> ]
> | I just don't like the idea of a library outputting things to
> | stdout/stderr all of a sudden (see fixup_null_alloc in xmalloc.c).
> |
> | In addition, right now you don't check the return value within
> | FreeIPMI when you call xmalloc(), so there are segfault possibilities.
> `----
> Running out of memory is an exceptional case.
> error () prints the message to stderr and calls exit ().
>
> It is easier to troubleshoot if the app dies as soon as it runs out of
> memory than causing some other failures at a later stage.
>
> You will not get segfault, because xmalloc will call exit if it runs
> out of memory. There is no need to check the return value of
> xmalloc. Thats the sole purpose of xmalloc.
>
> What do you think?
I agree with Al. What if you are running as a daemon and stderr is closed?
Or what if the application wants to clean up before exiting?
Better to return an error and let the application handle it IMHO.
Jim