Article View: comp.bugs.4bsd
Article #326Re: Complexity of reallocating storage (was users command crap)
From: Tim McDaniel
Date: Tue, 12 Feb 1991 22:39
Date: Tue, 12 Feb 1991 22:39
37 lines
2430 bytes
2430 bytes
mike@BRL.MIL (Michael John Muuss <mike>) writes:
Having programs not checking the error returns can make the job of
troubleshooting and repairing malfunctions much more difficult.
Yes, error checking can demand 3-4 times as much code as the actual
task at hand. For essential systems programs, and criticial user
applications, the error checking is well worth it.
A number of places, including Applied Dynamics (plug plug), use an
exception-handling library. If a function fails, it raises an
exception, causing the invocation of any code-specific exception
handlers (and, in some implementations, outputs a message if not
handled). Many implementations use preprocessor trickery at some
point, to make the code look nice.
There's an incredible feeling of freedom in simply writing
buf = MEMmalloc(STlen(s) + 1);
and knowing that the function won't return if it fails, and to write
the one line
EMMfatal("MEMmalloc", MEMoutOfMemory, "");
to do everything needed to wrap up the program with an informative
message. We have much more robust code as a result of such a library.
Also, error handling is centralized, so all the messages have the same
appearance, and it's easy to redirect them to a new destination.
This topic has been discussed in comp.lang.c before, and it's not
relevant to C per se anyway, so I won't go into more details.
--
"I'd hang you from my nipples ... but it would shock the children."
Tim McDaniel Applied Dynamics Int'l.; Ann Arbor, Michigan, USA
Internet: mcdaniel@adi.com UUCP: {uunet,sharkey}!amara!mcdaniel
Technical Details
Message-ID:
<MCDANIEL.91Feb12173940@dolphin.adi.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!caen!math.lsa.umich.edu!sharkey!amara!mcdanielReferences:
<21548@yunexus.YorkU.CA> <5883:Feb102:05:4991@kramden.acf.nyu.edu> <1991Feb2.045119.22199@zoo.toronto.edu> <14994:Feb207:10:4791@kramden.acf.nyu.edu> <15076@smoke.brl.mil>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!caen!math.lsa.umich.edu!sharkey!amara!mcdaniel From: mcdaniel@adi.com (Tim McDaniel) Newsgroups: comp.bugs.4bsd Subject: Re: Complexity of reallocating storage (was users command crap) Message-ID: <MCDANIEL.91Feb12173940@dolphin.adi.com> Date: 12 Feb 91 22:39:40 GMT References: <21548@yunexus.YorkU.CA> <5883:Feb102:05:4991@kramden.acf.nyu.edu> <1991Feb2.045119.22199@zoo.toronto.edu> <14994:Feb207:10:4791@kramden.acf.nyu.edu> <15076@smoke.brl.mil> Sender: news@adi.COM Followup-To: comp.bugs.4bsd Organization: Applied Dynamics International, Inc.; Ann Arbor, Michigan, USA Lines: 37 In-reply-to: mike@BRL.MIL's message of 4 Feb 91 22:11:46 GMT