home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20156 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  2.5 KB

  1. From: mcknight@etcetc.fidonet.org (Chuck McKnight)
  2. Sender: uucp@etcetc.fidonet.org
  3. Path: sparky!uunet!drd!etcetc!uucp
  4. Newsgroups: comp.lang.c
  5. Subject: Re: Need info for Turbo-C on storing lots of data within sourc
  6. Message-ID: <727918967.AA01099@etcetc.fidonet.org>
  7. Date: Sat, 23 Jan 1993 08:41:01 -0600
  8. Lines: 69
  9.  
  10.  NS>From: noah@ucscb.UCSC.EDU (Noah Spurrier)
  11.  NS>Organization: University of California; Santa Cruz
  12.  
  13.  
  14.  NS>Keywords: Turbo C data
  15.  
  16.  NS>I have a program that stores a compressed picture of its title
  17.  NS>screen. The
  18.  NS>title screen is a graphic image. Also the program stores some
  19.  NS>documentation.
  20.  NS>The program is fairly short. I do not want to store this data in
  21.  NS>separate files. What I did is use HUGE arrays with initialization
  22.  NS>to the
  23.  NS>big chunk of data. This works fine, but I notice that some people
  24.  NS>have had
  25.  NS>the program crash with something like the following error:
  26.  
  27.  NS>STACK OVERFLOW
  28.  
  29.  >or 
  30.  
  31.  NS>STACK FULL, SYSTEM HALTED
  32.  
  33.  NS>Another person told me that these huge arrays were being stored in
  34.  >the
  35.  NS>stack segment and that because they just sit on the stack and never
  36.  NS>move
  37.  NS>this does not give my program much room to work with.
  38.  
  39.  NS>Would simply making the array STATIC help things?
  40.  
  41.  NS>I also farmalloc a 64K buffer, but I don't think that should hurt
  42.  NS>the stack
  43.  NS>at all. 
  44.  
  45.  NS>How can I get Turbo-C to store these variables in the data segment
  46.  NS>instead of
  47.  NS>the stack?
  48.  
  49.  NS>Here is an example of how I declare and initialize one of my
  50.  NS>arrays:
  51.  NS>unsigned char far TITLE_DATA [(X_TITLE*Y_TITLE/4)] =
  52.  NS>{ 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
  53.  NS>85, 85, 85, 85,
  54.  NS>  85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
  55.  NS>85, 85, 85, 85,
  56.  NS>  85, 85, 85, 85, 85, 85,117, 85, 85, 85,117, 85, 85, 85,117, 85,
  57.  NS>85,213, 85, 85,
  58.  NS>  85, 85, 85, 85, 85, 87,213, 85, 85, 87,213, 85, 85, 87,213, 85,
  59.  NS>95, 85, 85, 85,
  60.  NS>  85, 85, 85, 85, 85,127,213, 85, 85,127, 85, 85, 85,127, 85,
  61.  NS>85,255, 85, 85, 85,
  62.  NS>  85, 85, 85, 85, 85,255,213, 85, 85,253, 85, 85, 85,253, 85,
  63.  NS>87,255, 85, 85, 85,
  64.  
  65.  NS>....
  66.  NS>....};
  67.  
  68.  NS>Thanks for even bothering to read this damn thing!
  69.  
  70. What memory model are you using?  If you're doing this in the small memory
  71. model, realize that your code and data segments are the same thing.  Try going
  72. to the large memory model (biggest benefit is that you don't have to use the
  73. far modifier as your pointers are automatically far pointers).  Just some
  74. ideas.
  75.  
  76. Chuck McKnight
  77.  
  78.  
  79.