Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!uunet!twwells!bill From: bill@twwells.com (T. William Wells) Newsgroups: comp.lang.c Subject: Re: Discarded Function Values (To Cast or Not to Cast) Message-ID: <1989Nov22.092719.26256@twwells.com> Date: 22 Nov 89 09:27:19 GMT References: <316@voa3.UUCP> <1989Nov17.154621.2698@aqdata.uucp> <1989Nov18.062322.12728@twwells.com> <11644@smoke.BRL.MIL> <1989Nov19.171815.17445@twwells.com> <11161@riks.csl.sony.co.jp> Organization: None, Ft. Lauderdale, FL Lines: 25 In article <11161@riks.csl.sony.co.jp> diamond@ws.sony.junet (Norman Diamond) writes: : What DO you do about calls to malloc? Something like: extern void *real_alloc(); #ifdef lint static void fake_alloc(n) unsigned n; { (void)real_alloc(n); } #define myalloc(x) (fake_alloc(x), 0) #else #define myalloc(x) real_alloc(x) #endif When lint is not defined, myalloc just goes to real_alloc, which does things like checking for out of memory after the call to malloc. When lint is defined, myalloc has the call to fake_alloc in order to type check its argument, and the zero is what the cast that goes with the myalloc sees. Lint doesn't mind casting the zero, so there are no complaints. --- Bill { uunet | novavax | ankh | sunvice } !twwells!bill bill@twwells.com