How do I keep pointers aligned?

Henry Spencer henry at utzoo.uucp
Tue Oct 10 12:17:20 AEST 1989


In article <12879 at s.ms.uky.edu> sean at ms.uky.edu (Sean Casey) writes:
>Lint tells me I have possible pointer alignment problems.
>s = (STUFF *) malloc((unsigned) sizeof(STUFF));


The problem is that lint has no way of knowing that the `char *' returned
by malloc is sufficiently well-aligned for use as a `STUFF *'.  In fact,
it is -- that's part of the specs of malloc -- but lint doesn't know that.

In practice, "possible pointer alignment problem" just means "better look
twice to make sure this is right".  It doesn't mean "this is wrong".
-- 
A bit of tolerance is worth a  |     Henry Spencer at U of Toronto Zoology
megabyte of flaming.           | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.unix.wizards mailing list