Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!ukc!its63b!simon From: simon@its63b.ed.ac.uk (Simon Brown) Newsgroups: comp.lang.c,comp.unix.wizards Subject: pointer alignment when int != char * Message-ID: <493@its63b.ed.ac.uk> Date: Mon, 22-Jun-87 04:39:37 EDT Article-I.D.: its63b.493 Posted: Mon Jun 22 04:39:37 1987 Date-Received: Sat, 4-Jul-87 17:30:29 EDT Reply-To: simon@its63b.ed.ac.uk (Simon Brown) Organization: Computer Science Department, Edinburgh University Lines: 23 Xref: mnetor comp.lang.c:2808 comp.unix.wizards:3096 If I were to want to implement malloc (or some such) on a machine where sizeof(int) != sizeof(char *), how do I ensure that the pointer-values I return are maximally aligned (eg, quad-aligned)? If sizeof(int)==sizeof(char *), then I can cast the pointer to an int, do whatever arithmetic stuff is required to it to get it to be aligned, then cast it back again - but of course this won't work if information is lost by either of the casts. Any hints? (BTW, It's not really malloc I'm dealing with, I just lied about that one) %{ Simon! %} -- ---------------------------------- | Simon Brown | UUCP: seismo!mcvax!ukc!its63b!simon | Department of Computer Science | JANET: simon@uk.ac.ed.its63b | University of Edinburgh, | ARPA: simon%its63b.ed.ac.uk@cs.ucl.ac.uk | Scotland, UK. | ---------------------------------- "Life's like that, you know"