From owner-freebsd-hackers Fri Mar 30 7:37:12 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from umbar.vaxpower.org (isildur.icubed.com [208.0.146.176]) by hub.freebsd.org (Postfix) with SMTP id 1418337B71F for ; Fri, 30 Mar 2001 07:37:08 -0800 (PST) (envelope-from mrfusion@umbar.vaxpower.org) Received: by umbar.vaxpower.org (5.65/DEC-Ultrix/4.3) id AA23527; Fri, 30 Mar 2001 10:37:29 -0500 Date: Fri, 30 Mar 2001 10:37:28 -0500 (EST) From: Lord Isildur Subject: Re: Question regarding the array of size 0. To: John Franklin Cc: tech-kern@netbsd.org, freebsd-hackers@FreeBSD.ORG In-Reply-To: <20010330101929.B24999@elfie.org> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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