freeipmi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [llnl-devel] Re: [Freeipmi-devel] xmalloc


From: Albert Chu
Subject: Re: [llnl-devel] Re: [Freeipmi-devel] xmalloc
Date: Tue, 30 Dec 2003 16:41:33 -0800

> Running out of memory is an exceptional case. 
> error () prints the message to stderr and calls exit ().

Perhaps this a "philosophical" thing to me, but my opinion is that
libraries should never fail/exit unless it is a fatal error and bug
within the library (for example failing at an assert()).

It is ok for applications to exit on a malloc error, b/c that is the
choice of the developer.  But if we are developing a library for other
developers to use, I don't think a library should make the choice for
them.  This is the same reason why we return errnos for sendto(),
recvfrom(), write(), etc.

Al

--
Albert Chu
address@hidden
Lawrence Livermore National Laboratory

----- Original Message -----
From: Anand Babu <address@hidden>
Date: Tuesday, December 30, 2003 3:59 pm
Subject: Re: [llnl-devel] Re: [Freeipmi-devel] xmalloc

> ,----[ 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?
> 
> -- 
> Anand Babu
> Free as in Freedom <www.gnu.org>
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]