Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: Re: Malloc problems
Message-ID: <1988May17.184525.14461@utzoo.uucp>
Organization: U of Toronto Zoology
References: <272@marob.MASA.COM> <690008@hpfelg.HP.COM>, <13371@tut.cis.ohio-state.edu>
Date: Tue, 17 May 88 18:45:25 GMT

> Good (in my estimation) code would test any and all dynamically allocated
> memory for successful completion of the malloc() call.  

Definitely.  A good way to do this for garden-variety programs is to have
a library function emalloc() which calls malloc, checks the result, and
prints a message and exits if NULL.  This is *not* appropriate for use from
library functions or in programs that want to do non-trivial error recovery,
but it is extremely useful in situations where it is known that nothing
useful can be done on running out of memory.
-- 
NASA is to spaceflight as            |  Henry Spencer @ U of Toronto Zoology
the Post Office is to mail.          | {ihnp4,decvax,uunet!mnetor}!utzoo!henry
