Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: Dumb question on dyn. mem. alloc (if(hate(novices)) dont_read();) Message-ID: <921@umcp-cs.UUCP> Date: Sat, 20-Jul-85 03:08:58 EDT Article-I.D.: umcp-cs.921 Posted: Sat Jul 20 03:08:58 1985 Date-Received: Sun, 21-Jul-85 03:44:11 EDT References: <1035@homxa.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 32 Lint doesn't realize that malloc and calloc have been written such that that "possible pointer alignment problem" never occurs. The thing to do is ignore the message (or teach lint how to say that a function returns a ``very aligned'' pointer; someone once suggested using /*ALIGNOK*/ similar to the way /*NOTREACHED*/ and /*ARGSUSED*/ tell lint not to complain). Another alternative is to use code like this: struct foo * getfoo() { struct foo *p; #ifdef lint p = NULL; #else p = (struct foo *)malloc((unsigned)sizeof (struct foo)); if (p == NULL) error(1, errno, "out of memory in getfoo"); p->this = p->that = theotherthing; #endif return (p); } since lint knows that ``p = 0'' is not assigning an unaligned pointer to p. Of course this loses the type checking in the rest of the code. (Sigh.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland