TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: STEVE WESTCOT
from: JERRY COFFIN
date: 1997-05-30 19:01:00
subject: Array size too big.

On (29 May 97) Steve Westcot wrote to All...
 SW> Here is my structure, and the array size I want:
 SW> struct maptile {
 SW>    char         type; //What the map tile looks like
 SW>    unsigned int x, y; //Map tile coordinates
 SW>    int          attr; //Map Attributes...specifics not listed
 SW>    char         special[81]; //Special field for map attributes
 SW>    char         text[341]; //Map tile Description
 SW>    int          ansifg, ansibg, ansiattr; //Ansi colors and attributes
 SW> }
 SW> int main(void) {
 SW>    maptile      local_map[9][21]; /* Size of Display area plus 1 tile
 SW>                                      buffer on each side of Display */
 SW>    return 0;
 SW> }
 SW> As I said previously, if I need to alter my structure I can...341
 SW> characters per tile for a description can be reduced.
Well, as-is, that's over 80K of storage.  Assuming you're running on
DOS, your stack is limited to an absolute maximum of 64K, and the rest
of your program likely occupies some of that.  To reduce this to, say,
60K, we have 325 bytes per structure, leaving no more than 231 bytes for
`text'.  You'll likely have to tell your compiler you want a 64K stack
to get that to work - most set the stack to around 4 or 8K by default.
Alternatively, you might want to allocate `local_map' dynamically so it
won't take up nearly your entire stack.  That would also allow you to
leave it at roughly the original size, or even expand it if you prefer.
The function to do a huge allocation (i.e. one over 64K) depends on the
compiler you use.  Probably the easiest method of dealing with this is
to pick up a copy of Snippets which includes a header (hugealloc.h ?)
that figures out what compiler you're using, and picks the correct
function name to use.
    Later,
    Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.