home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / msdos / programm / 9070 < prev    next >
Encoding:
Internet Message Format  |  1992-09-07  |  3.1 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!cleveland.Freenet.Edu!bu254
  2. From: bu254@cleveland.Freenet.Edu (Stephen Groundwater)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Re: New and farcoreleft()
  5. Date: 5 Sep 1992 03:45:24 GMT
  6. Organization: Case Western Reserve University, Cleveland, OH (USA)
  7. Lines: 52
  8. Message-ID: <189agkINN4jd@usenet.INS.CWRU.Edu>
  9. References: <1992Sep4.051057.26963@news2.cis.umn.edu> <1992Sep3.134102.17553@news2.cis.umn.edu> <HOLLEN.92Sep3114500@peg.megatek.UUCP>
  10. Reply-To: bu254@cleveland.Freenet.Edu (Stephen Groundwater)
  11. NNTP-Posting-Host: hela.ins.cwru.edu
  12.  
  13.  
  14. In a previous article, wright@epx.cis.umn.edu (Mark Wright) says:
  15.  
  16. >In article <HOLLEN.92Sep3114500@peg.megatek.UUCP> hollen@megatek.UUCP (Dion Hollenbeck) writes:
  17. >>In article <1992Sep3.134102.17553@news2.cis.umn.edu>
  18. >>wright@epx.cis.umn.edu (Mark Wright) writes:
  19. >>
  20. >>Mark>      In a C++ program I've been writing, strategically placed
  21. >>Mark>   farcoreleft()'s seem to be saying that my objects are not being
  22. >>Mark>   de-allocated correctly when I 'destroy' them.  Should I worry about
  23. >>Mark>   this, or is farcoreleft() designed for use with malloc()?  If so,
  24. >>Mark>   is there a C++ function which will tell me how much mem. I have
  25. >>Mark>   left?  I'm using Borland C++ v3.1.
  26. >>
  27. >>Yes it is designed for use with malloc().  It is probably working
  28. >>correctly, you probably do not know how it is working.
  29. >[...]
  30. >>-- 
  31. >>Dion Hollenbeck       UUCP: {uunet, ucsd, sun}!megatek!hollen
  32. >>                      INTERNET:            hollen@megatek.com
  33. >>Megatek Corporation  9645 Scranton Rd.  San Diego, Ca.  92121
  34. >
  35. >I don't think I stated my problem very clearly.  My concern is that allocating
  36. >space with 'new' may confuse farcoreleft().  I know that combining C style 
  37. >memory allocation routines (ie. malloc()) and C++ memory allocation routines
  38. >(ie. new) will cause problems - I guess what I want to know is 'Is 
  39. >farcorleft() C++ aware?'  Does farcoreleft() know about 'new', or is it
  40. >specifically a C function.  And if so, is there a C++ version of farcoreleft()?
  41. >
  42. This problem does not occur, new is a function, just like any other, and
  43. when it is called it uses the standard routines to get its memory. So
  44. that:
  45. buf=(char *)new char[100];
  46. is functionally equivilent too, and is turned into eventually:
  47. buf=(char *)malloc(100);
  48. Well, you get the jist of it anyway. Your problem
  49. is a non-problem. If you are really paranoid, you could define
  50. a new
  51. operator new () {}
  52. for all your classes with your own memory allocation done there.
  53.  
  54. The thing that most concerns me is that you talk of malloc with farcoreleft
  55. you better be sure you are using the large, compact or huge models there,
  56. otherwise you should be using farmalloc (or equivilent in your compiler)
  57. because otherwise you are allocating memory in the data segment, an area 
  58. of memory that does not change size for farcoreleft, because the data 
  59. segment is allocated when the program starts, and is dumped when the 
  60. program stops, and doesn't change size when the program is running.
  61. And the memory is allocated by the compiler with no reference to things
  62. that are far.
  63.  
  64. Steve
  65.