Re: What to do when malloc() returns 0?

>        A. Fatal exit.
>                + easy to code
>                - unsuitable for editing apps
>                - unsuitable for DOS/Windows, other small-memory machines
>                - makes the library unusable from otherwise robust
>                        applications
>
>        B. Call fatal-exit hook function
>                + easy to code
>                + allows editing apps to do "last ditch save"
>                + allows graceful exit on small-memory machines
>                - still unsuitable for integration with otherwise
>                        robust apps
>
>        C. Raise an exception -- export exception API to library
>                        clients
>                - requires significant library reengineering
>                - requires integration of external technology
>                        (who's exception package do we use?)
>                - requres library clients to use exceptions API
>                + allows robust editing applications to use the library
>
>        D. Raise an exception, catch it before exiting the API,
>                return an error code
>                - requires significant library reengineering
>                - requires integration of external technology
>                        (who's exception package do we use?)
>                - requires distinction between "public" API and
>                        "internal" API
>                - requires library clients to do lots of error checking
>                + suitable for use in robust applications
>
>        E. Support "malloc failed" return code throughout the library
>                - requires significant library reengineering
>                - error prone
>                - requires library clients to do lots of error checking
>                + suitable for use in robust applications
>
Yup, I think Dan pretty much hit the nail on the head here! This is a
significant deficiency of the current libwww. Not so much a problem for the
unix type boxes, but a major deficiency elsewhere. As far as I am
concerned, if my program exits, it is a bug (unfortunately, I program a
Mac). The setjmp, longjump solution is very close to how I work around this
problem right now (I jump all the way out of the library, very dirty), but
the cleanup problem can't be ignored. I think a re-engineering of the
mechanism is in order. A DCE style solution looks very attractive to me.

Thomas Redman (redman@ncsa.uiuc.edu)
Software Development Group, National Center for Supercomputing Applications
University of Illinois, Urbana-Champaign
(217) 244-0781; fax (217) 244-1987

Received on Thursday, 21 July 1994 15:24:45 UTC