🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9640

Re: Block Initialization

#9640
From: Tom Stockfisch
Date: Thu, 23 Oct 1986 20:35
29 lines
1637 bytes
In article <3965@umcp-cs.UUCP> chris@umcp-cs.UUCP (Chris Torek) writes:
>>>The chore is to initialize the entire structure to zero.  How do I do it?
>
>Structure assignment is fine in most cases, but suppose instead that
>some hapless programmer is supposed to initialise a 40K-byte structure
>using a small model compiler on an IBM PC?  There is no space for a
>second copy of the structure.  Using bzero() here (assuming it exists,
>or after writing it) is reasonable, given the compiler limitations.

The obvious solution is to make assignment of zero to any structure a
defined operation guaranteed to get the appropriate bit patterns into
all the pointer elements.  Much cleaner than

	struct big_sucker { ... }	zero;	/* initialized to all zeros */
	main()
	{
		struct big_sucker	var;
		...
		var =	zero;	/* clear all elements of var */
		...
	}

would be
		var =	0;	/* (no comment needed) */

and much better for portability than using bzero().
I hope this gets provided for in ANSI C.

-- Tom Stockfisch, UCSD Chemistry
Technical Details
Message-ID: <414@sdchema.sdchem.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!decvax!ucbvax!sdcsvax!sdchem!tps
References: <586@calma.UUCP> <4510@brl-smoke.ARPA> <3965@umcp-cs.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!decvax!ucbvax!sdcsvax!sdchem!tps
From: tps@sdchem.UUCP (Tom Stockfisch)
Newsgroups: net.lang.c
Subject: Re: Block Initialization
Message-ID: <414@sdchema.sdchem.UUCP>
Date: Thu, 23-Oct-86 16:35:46 EDT
Article-I.D.: sdchema.414
Posted: Thu Oct 23 16:35:46 1986
Date-Received: Fri, 24-Oct-86 04:56:08 EDT
References: <586@calma.UUCP> <4510@brl-smoke.ARPA> <3965@umcp-cs.UUCP>
Sender: news@sdchem.UUCP
Reply-To: tps@sdchemf.UUCP (Tom Stockfisch)
Distribution: na
Organization: UC San Diego
Lines: 29