Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utcs!flaps From: flaps@utcs.UUCP Newsgroups: net.unix,net.unix-wizards,net.arch,net.lang.c Subject: Re: get size of malloc'd object Message-ID: <1986Jun27.01:36:11.4839@utcs.uucp> Date: Fri, 27-Jun-86 01:36:11 EDT Article-I.D.: utcs.1986Jun27.01:36:11.4839 Posted: Fri Jun 27 01:36:11 1986 Date-Received: Fri, 27-Jun-86 01:39:01 EDT References: <165@daisy.UUCP> <334@valid.UUCP> <2206@peora.UUCP> <2081@umcp-cs.UUCP> <2216@peora.UUCP> Reply-To: flaps@utcs.UUCP (Alan J Rosenthal) Organization: University of Toronto Lines: 25 Xref: utcs net.unix:8357 net.unix-wizards:17930 net.arch:3543 net.lang.c:9410 A way to get a sufficient alignment constant should be as follows: union ALIGNED { char garbage0; unsigned char garbage1; short garbage2; int garbage3; unsigned garbage4; long garbage5; unsigned long garbage6; float garbage7; double garbage8; }; (sorry if I've left out any) Then you can use sizeof(ALIGNED) as the alignment constant. Am I mistaken? The problem is that this number might be greater than the actual alignment constant, for example if a "double" has length 8 but only needs quad-word alignment. -- Alan J Rosenthal {decvax|cbosgd|linus}!ihnp4!utcs!flaps, utzoo!utcs!flaps