Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!caip!clyde!cuae2!ltuxa!we53!sw013b!dj3b1!killer!ndmce!pollux!bobkat!pedz From: pedz@bobkat.UUCP (Pedz Thing) Newsgroups: net.lang.c Subject: Re: Block Initialization Message-ID: <161@bobkat.UUCP> Date: Mon, 13-Oct-86 16:56:02 EDT Article-I.D.: bobkat.161 Posted: Mon Oct 13 16:56:02 1986 Date-Received: Fri, 17-Oct-86 03:36:17 EDT References: <586@calma.UUCP> Reply-To: pedz@bobkat.UUCP (Pedz Thing) Distribution: na Organization: Digital Lynx; Dallas, TX Lines: 36 In article <586@calma.UUCP> swang@calma.UUCP (Sin-Yaw Wang) writes: >What is the most suitable (fast and portable among versions of Unix) >way to do block initialization? > If you have an extra 4k of memory space I do the following: ---------- static struct bigstruct zerobigstruct; main() { struct bigstruct tobeused; tobeused = zerobigstruct; ... } ---------- The above code obviously assumes that the compiler has structure assignment which I think is a pretty safe assumption if you are dealing with C compilers on Unix machines. I realize that this is going to start the big debate about assignment of structures being either field by field or a block move. Lets not get into that argument please. My point here is if the compiler feels a block move for the above code is correct then it can produce that. If the compiler prefers field by field assignment, it can produce that. (I personally assume the above code produces a block move and if that is not what I want, then I must explicitly tell the compiler otherwise). -- Perry Smith ctvax ---\ megamax --- bobkat!pedz pollux---/