Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!caen!sdd.hp.com!cs.utexas.edu!uwm.edu!linac!att!att!cbnewsk!ech From: ech@cbnewsk.att.com (ned.horvath) Newsgroups: comp.sys.mac.programmer Subject: Re: Why won't ResError return the right message? Message-ID: <1991May8.031012.1845@cbnewsk.att.com> Date: 8 May 91 03:10:12 GMT References: <12946@pt.cs.cmu.edu> Organization: AT&T Bell Laboratories Lines: 27 From article <12946@pt.cs.cmu.edu>, by hairston@henry.ece.cmu.edu (David Hairston): > there's a no-brainer which has worked its way into my code (C example): > #define goodHand(x) ((x) && *(x)) > > which gets used for: > > realHandle = GetResource(type, index); > if (!goodHand(realHandle)) > .... Your no-brainer misses two potential problems: - if I call it with, say, "goodHand (myH++)" (or any other expression with side-effects) things get ugly (and VERY hard to debug!). - there is a distinction between handle==NULL and *handle==NULL for resources: a NULL handle either doesn't exist or hasn't been initialized, whereas a non-null resource handle which dereferences to a NULL indicates a purged resource -- call LoadResource to pull the data in. =Ned Horvath= -- =Ned Horvath= ehorvath@attmail.com