Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Mar 2001 10:37:28 -0500 (EST)
From:      Lord Isildur <mrfusion@umbar.vaxpower.org>
To:        John Franklin <franklin@elfie.org>
Cc:        tech-kern@netbsd.org, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Question regarding the array of size 0.
Message-ID:  <Pine.3.89.10103301045.B22782-0100000@umbar>
In-Reply-To: <20010330101929.B24999@elfie.org>

next in thread | previous in thread | raw e-mail | index | archive | help
sine one knows the size of the struct, who need the pointer? just 
take the displacement. 

char* buf; /* some buffer */
struct foo{
int header;
struct funkystruct blah;
};

(struct foo*)buf; /*your headers are here */
(struct foo*)buf+1; /* and your data is here */


Isildur

On Fri, 30 Mar 2001, John Franklin wrote:
> 
> You can then read in a block of memory from a file or socket, cast the
> buffer to that data type and have the header and data all accessable 
> via the same structure while leaving the sizeof(struct foo) equal
> to the header's size.
> 
> jf
> -- 
> John Franklin
> franklin@elfie.org
> ICBM: N37 12'54", W80 27'14" Z+2100'
> 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.3.89.10103301045.B22782-0100000>