FAQ - malloc array - clarify
Chris Torek
chris at mimsy.umd.edu
Sun Sep 9 07:22:58 AEST 1990
In article <1990Sep08.022034.8444 at virtech.uucp> cpcahil at virtech.uucp
(Conor P. Cahill) writes:
[re the lint error from `ptr = malloc(expr * sizeof(sometype))':
malloc, arg. 1 used inconsistently]
>This is caused by the argument to malloc being unsigned, not signed. A
>cast in your code will fix this.
Note that the cast is only required in old, broken compilers where the
result of `sizeof' is an int instead of a size_t (typically unsigned
int). These compilers are remarkably widespread (and, unfortunately,
fixing them breaks some existing code, which is why I have not fixed
ours here yet).
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain: chris at cs.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list