🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #33085

Re: MWC & large arrays -- help!

#33085
From: Leo de Wit
Date: Fri, 01 Jul 1988 16:55
48 lines
2055 bytes
In article <2073@alliant.Alliant.COM> rosenkra@alliant.UUCP (Bill Rosenkranz) writes:
>regarding large arrays, are we talking about local arrays (defined inside a
>function) or globals? i know that even the first st version of alcyon
>(for example) has no problems with a global like
>
>	unsigned int	array[100000];
>
>though local arrays of this size are probably not possible (have never even
>needed to try it out).
>
>an obvious solution to this whole problem is to Malloc (not malloc) the space
>and then refer to the pointer. this works with 1 dimensional arrays but
>multidimensional arrays would be tricky.
>
>-bill

Just specify the correct pointer type, for instance if you want an
array of this type:

    unsigned int array[200][500];

then your pointer should be declared:

    int (*arrp)[500]; /* that's just 1 pointer, for pointing to an int [500];*/

you initiate it as follows:

    arrp = (int (*)[500])Malloc(200 * sizeof(*arrp)); /* isn't that nice 8-) */

and now you can say for instance:

    arrp[155][430] = 12345;

In fact you can use all normal pointer conversions, such as sizeof, *,
&, [], 'arrp' being a pointer of the same type as 'array'.

Note that the () are obligatory;

    int *arrp[500];

are 500 pointers to int, and that's something quite different!

As for big auto arrays, that should be avoided; the most effective
addressing mode for them being a word offset from the frame pointer (so
a restriction of 32K). Of course you can use big static arrays if the
function is not used recursive; these are local too.

    Leo.
Technical Details
Message-ID: <542@philmds.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!philmds!leo
References: <734@cacilj.UUCP> <46700008@hcx2> <411@brambo.UUCP> <767@lakesys.UUCP> <2921@tekig5.TEK.COM> <2073@alliant.Alliant.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!philmds!leo
From: leo@philmds.UUCP (Leo de Wit)
Newsgroups: comp.sys.atari.st
Subject: Re: MWC & large arrays -- help!
Message-ID: <542@philmds.UUCP>
Date: 1 Jul 88 16:55:05 GMT
References: <734@cacilj.UUCP> <46700008@hcx2> <411@brambo.UUCP> <767@lakesys.UUCP> <2921@tekig5.TEK.COM> <2073@alliant.Alliant.COM>
Reply-To: leo@philmds.UUCP (Leo de Wit)
Organization: Philips I&E DTS Eindhoven
Lines: 48