home *** CD-ROM | disk | FTP | other *** search
- From: mcknight@etcetc.fidonet.org (Chuck McKnight)
- Sender: uucp@etcetc.fidonet.org
- Path: sparky!uunet!drd!etcetc!uucp
- Newsgroups: comp.lang.c
- Subject: Re: Need info for Turbo-C on storing lots of data within sourc
- Message-ID: <727918967.AA01099@etcetc.fidonet.org>
- Date: Sat, 23 Jan 1993 08:41:01 -0600
- Lines: 69
-
- NS>From: noah@ucscb.UCSC.EDU (Noah Spurrier)
- NS>Organization: University of California; Santa Cruz
-
-
- NS>Keywords: Turbo C data
-
- NS>I have a program that stores a compressed picture of its title
- NS>screen. The
- NS>title screen is a graphic image. Also the program stores some
- NS>documentation.
- NS>The program is fairly short. I do not want to store this data in
- NS>separate files. What I did is use HUGE arrays with initialization
- NS>to the
- NS>big chunk of data. This works fine, but I notice that some people
- NS>have had
- NS>the program crash with something like the following error:
-
- NS>STACK OVERFLOW
-
- >or
-
- NS>STACK FULL, SYSTEM HALTED
-
- NS>Another person told me that these huge arrays were being stored in
- >the
- NS>stack segment and that because they just sit on the stack and never
- NS>move
- NS>this does not give my program much room to work with.
-
- NS>Would simply making the array STATIC help things?
-
- NS>I also farmalloc a 64K buffer, but I don't think that should hurt
- NS>the stack
- NS>at all.
-
- NS>How can I get Turbo-C to store these variables in the data segment
- NS>instead of
- NS>the stack?
-
- NS>Here is an example of how I declare and initialize one of my
- NS>arrays:
- NS>unsigned char far TITLE_DATA [(X_TITLE*Y_TITLE/4)] =
- NS>{ 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
- NS>85, 85, 85, 85,
- NS> 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
- NS>85, 85, 85, 85,
- NS> 85, 85, 85, 85, 85, 85,117, 85, 85, 85,117, 85, 85, 85,117, 85,
- NS>85,213, 85, 85,
- NS> 85, 85, 85, 85, 85, 87,213, 85, 85, 87,213, 85, 85, 87,213, 85,
- NS>95, 85, 85, 85,
- NS> 85, 85, 85, 85, 85,127,213, 85, 85,127, 85, 85, 85,127, 85,
- NS>85,255, 85, 85, 85,
- NS> 85, 85, 85, 85, 85,255,213, 85, 85,253, 85, 85, 85,253, 85,
- NS>87,255, 85, 85, 85,
-
- NS>....
- NS>....};
-
- NS>Thanks for even bothering to read this damn thing!
-
- What memory model are you using? If you're doing this in the small memory
- model, realize that your code and data segments are the same thing. Try going
- to the large memory model (biggest benefit is that you don't have to use the
- far modifier as your pointers are automatically far pointers). Just some
- ideas.
-
- Chuck McKnight
-
-
-