lkml.org 
[lkml]   [2001]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Newbie idiotic questions.
Date
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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:55    [W:0.111 / U:0.456 seconds]
©2003-2011 Jasper Spaans. Advertise on this site