Article View: alt.sources.d
Article #982Re: Allocate 4D arrays in C
From: william E Davidsen
Date: Thu, 12 Nov 1992 21:37
Date: Thu, 12 Nov 1992 21:37
27 lines
1946 bytes
1946 bytes
In article <1992Nov11.170621.23765@osf.org>, elliston@osf.org (David Elliston) writes:
| I always prefered the (less portable but) more general approach. The
| function eallocN takes an 0-terminated array of integers specifying the size
| of each dimension, together with the size of the type being allocated.
| Excuse the butchered Hungarian.
[ proposed solution deleted ]
As I read the ANSI standard, your solution is non-portable. You assume
that the format of all pointers is identical, when in fact on some
machines (and the standard as I read it) they are not, nor are they
required to be. Thus (void *) pointers need not be the same format or
even size as pointers to other types. This was brought up at one of the
X3J11 meetings by the representative from DG, and I believe he indicated
that char* pointers were 48 bits while all others were 32. Don't quote
me on the sizes.
The solution shown will work on Suns and VAXen, but I don't believe
it's completely portable. That's one of the reasons I used typing in
mine, to avoid failure due to assumptions about the size of pointers.
The proposed solution assumes sizeof all pointers equal, and I don't
believe that's so.
--
bill davidsen, GE Corp. R&D Center; Box 8; Schenectady NY 12345
Keyboard controller has been disabled, press F1 to continue.
Technical Details
Message-ID:
<1992Nov12.213721.7152@crd.ge.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!think.com!rpi!crdgw1!rdsunx.crd.ge.com!ariel!davidsenReferences:
<1992Nov11.154140.16397@crd.ge.com> <1992Nov11.170621.23765@osf.org>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!think.com!rpi!crdgw1!rdsunx.crd.ge.com!ariel!davidsen From: davidsen@ariel.crd.GE.COM (william E Davidsen) Newsgroups: alt.sources.d Subject: Re: Allocate 4D arrays in C Message-ID: <1992Nov12.213721.7152@crd.ge.com> Date: 12 Nov 92 21:37:21 GMT References: <1992Nov11.154140.16397@crd.ge.com> <1992Nov11.170621.23765@osf.org> Sender: usenet@crd.ge.com (Required for NNTP) Reply-To: davidsen@crd.ge.com (bill davidsen) Organization: GE Corporate R&D Center, Schenectady NY Lines: 27 Nntp-Posting-Host: ariel.crd.ge.com