On Sunday 17 June 2001 03:32, Jeff Garzik wrote:
> Bill Pringlemeir wrote:
> > Why is the struct type referenced for the allocation size?  Why not,
> >
> >         if ((card->mpuout = kmalloc(sizeof(card->mpuout), GFP_KERNEL))
>
> because then you would be allocating the size of a pointer, not the size
> of a structure

Whoops Jeff, you didn't have your coffee yet:

        struct foo { int a; int b; };
        struct { struct foo foo; } *foobar;

        int main (void)
        {
                printf("%i\n", sizeof(struct foo));
                printf("%i\n", sizeof(foobar->foo));
                printf("%i\n", sizeof(&foobar->foo));
        }

Prints:

        8
        8
        4
--
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to