Path: utzoo!utgpu!watserv1!watmath!att!bellcore!bellcore-2!rutgers!cbmvax!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.lang.c Subject: Re: FAQ - malloc array - clarify Keywords: malloc, Sun, lint Message-ID: <1990Sep11.002544.9151@virtech.uucp> Date: 11 Sep 90 00:25:44 GMT References: <8056@helios.TAMU.EDU> <1990Sep08.022034.8444@virtech.uucp> <1803@tuvie> Reply-To: cpcahil@virtech.UUCP (Conor P. Cahill) Organization: Virtual Technologies Inc., Sterling VA Lines: 23 In article <1803@tuvie> hp@vmars.tuwien.ac.at (Peter Holzer) writes: >cpcahil@virtech.uucp (Conor P. Cahill) writes: > >>This is caused by the argument to malloc being unsigned, not signed. A >>cast in your code will fix this. > >No! Don't fix your code, which is correct. Fix the lint library. >The argument to malloc should be the type returned by sizeof (): size_t >(an unsigned integral type). The argument to malloc is defined in the library (i.e. where malloc() is encoded). running lint against the source builds the lint library and therefore the lint library will correctly reflect what the code has (besides, without code, you can rebuild a lint library). The problem that the original poster ran into is that on his system the type of sizeof() is an integer. However, the type of malloc's argument is an unsigned integer. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170