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

  1. Path: sparky!uunet!math.fu-berlin.de!informatik.tu-muenchen.de!rz.uni-passau.de!hiwi170.rz.uni-passau.de!schmidt
  2. From: schmidt@rz.uni-passau.de (SCHMIDT GUIDO)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: DOS, BC++, Need, large data memory, how?
  5. Date: Sat, 23 Jan 1993 14:10:12 GMT
  6. Organization: University of Passau - Germany
  7. Lines: 51
  8. Message-ID: <schmidt.31@rz.uni-passau.de>
  9. References: <80362@hydra.gatech.EDU> <schmidt.21@rz.uni-passau.de> <RUNE.93Jan22073636@calypso.nta.no>
  10. NNTP-Posting-Host: hiwi170.rz.uni-passau.de
  11.  
  12. In article <RUNE.93Jan22073636@calypso.nta.no> rune@nta.no (Rune Henning Johansen FBA) writes:
  13.  
  14.  
  15. > > I've tried the following program with TCW 3.0 in model SMALL. It works fine.
  16.  
  17. >Thanks for the program! I didn't know about "farmalloc" before.  But
  18. >my problem is that I'm not able to link my program. (I should have
  19. >specified that, sorry!) When I'm able to run my program, I guess
  20. >"farmalloc" will be very useful in a redefined "new", but until then:
  21. >How can I link my program without getting: "Automatic data segment
  22. >exceeds 64K"?
  23.  
  24. > - Rune
  25.  
  26.  
  27.  
  28. Hello!
  29.  
  30. Since you use TCW as far as I understood your questions you can only use
  31. model LARGE as the biggest one. This gives you only 64k for the automatic 
  32. data segment per .cpp file. In the automatic data segment you find (as the
  33. name says) automatic data. I.e. variables which are local to a function and
  34. are not static. See the following example:
  35.  
  36.     void anyfunction() {
  37.         char largearray[50000]; // <-- automatic data
  38.         ...
  39.         largearray[1000] = 'A';
  40.         ...
  41.     }
  42.  
  43. You can get around this by using the heap/farheap with new, malloc or
  44. farmalloc. In the above example:
  45.  
  46.     void anyfunction() {
  47.         char * largearray;            // <-- takes only 2 or 4 bytes
  48.         largearray = new char[50000]; // 50000 bytes taken from heap
  49.         ...
  50.         largearray*[1000] = 'A';      // I'm not quite sure about
  51.                                       // this one
  52.         ...
  53.         delete largearray;            // free 50000 bytes from heap
  54.     }
  55.  
  56. Guido.
  57. --------------------------------------------------------------------
  58. - Guido Schmidt                                                    -
  59. - schmidt@rz.uni-passau.de                                         -
  60. - Universitaet Passau, Germany                                     -
  61. --------------------------------------------------------------------
  62.  
  63.