Malloc problems

Henry Spencer henry at utzoo.uucp
Wed May 18 04:45:25 AEST 1988


> 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



More information about the Comp.lang.c mailing list