Re: Newbie idiotic questions.

From: rjd@xyzzy.clara.co.uk
Date: Sun Jun 17 2001 - 07:27:35 EST


Daniel Phillips wrote:
>
> > 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:

Whoops yourself. The following patch brings your example into line with
the driver code. mpuout is a pointer to a structure not the structure itself
as the malloc assignment clearly indicates.

*** x.c-orig Sun Jun 17 13:19:33 2001
--- x.c Sun Jun 17 13:19:42 2001
***************
*** 2,8 ****
  
  
  struct foo { int a; int b; };
! struct { struct foo foo; } *foobar;
  
  int main (void)
  {
--- 2,8 ----
  
  
  struct foo { int a; int b; };
! struct { struct foo *foo; } *foobar;
  
  int main (void)
  {

Now Prints:

        8
        4
        4

-- 
        Bob Dunlop                      FarSite Communications
        rjd@xyzzy.clara.co.uk           bob.dunlop@farsite.co.uk
        www.xyzzy.clara.co.uk           www.farsite.co.uk
-
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/



This archive was generated by hypermail 2b29 : Sat Jun 23 2001 - 21:00:18 EST