Dynamic multidimensional arrays
Karl Heuer
karl at haddock.ISC.COM
Sat Jun 18 04:07:26 AEST 1988
In article <11989 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>>>In article <4556 at haddock.ISC.COM> karl at 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 <align.h> 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 at haddock.isc.com), The Walking Lint
More information about the Comp.lang.c
mailing list