Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!lll-crg!nike!ucbcad!ucbvax!hplabs!tektronix!teklds!copper!mikeb From: mikeb@copper.UUCP (Mike Beckerman) Newsgroups: net.lang.c Subject: Re: SWAP macro Message-ID: <461@copper.UUCP> Date: Mon, 7-Jul-86 16:34:00 EDT Article-I.D.: copper.461 Posted: Mon Jul 7 16:34:00 1986 Date-Received: Wed, 9-Jul-86 02:20:59 EDT References: <1577@brl-smoke.ARPA> <1212@bunker.UUCP> Reply-To: mikeb@copper.UUCP (Mike Beckerman) Organization: Tektronix, Inc., Beaverton, OR. Lines: 14 I'm a little behind on my news for net.lang.c, but of the articles about the "SWAP" macro which I've read several have some form of copy involved. By copy I mean the use of "memcopy", or a cast to character and copy, etc. These may work in many cases, but they could be quite harmful when used on objects which have the "volatile" storage class. For example, if the objects were ints, and the swap is implemented as swapping 4 characters for each int, then each of the two ints would be accessed in some part 8 times (4 to read old 4 bytes, 4 to write new 4 bytes). Any comments? Mike