Path: utzoo!attcan!uunet!husc6!think!ames!necntc!ima!haddock!karl
From: karl@haddock.ISC.COM (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: Dynamic multidimensional arrays
Message-ID: <4607@haddock.ISC.COM>
Date: 17 Jun 88 18:07:26 GMT
References: <10655@agate.BERKELEY.EDU> <1857@hubcap.UUCP> <8099@brl-smoke.ARPA> <11989@mimsy.UUCP>
Reply-To: karl@haddock.ima.isc.com (Karl Heuer)
Organization: Interactive Systems, Boston
Lines: 17

In article <11989@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>>>In article <4556@haddock.ISC.COM> karl@haddock.ima.isc.com (Karl Heuer)
>>>writes [that by using one big malloc for both the row vectors and the data
>>>area makes it simpler to deallocate the thing]
>
>The problem with this is alignment.

This is correct; if there are objects with stricter alignment than pointers,
you may need to insert a shim.  On any individual machine this is easy, but
without an  there's no absolute guarantee.  (But I'd bet aligning to
sizeof(double) would work on all current implementations.  This can be done
without mucking around with the pointer format, since the base pointer
returned by malloc() is already aligned.)

In any case, the use is portable even if the implementation details are not.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint