home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18377 < prev    next >
Encoding:
Text File  |  1992-12-23  |  1.8 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!gatech!udel!rochester!rocksanne!news
  3. From: Heliotis.ROCH803@xerox.com (Jim Heliotis)
  4. Subject: Overloading new without redefining new&delete?
  5. Message-ID: <1992Dec23.154447.17420@spectrum.xerox.com>
  6. Keywords: storage debug
  7. Sender: news@spectrum.xerox.com
  8. Reply-To: Heliotis.ROCH803@xerox.com
  9. Organization: Xerox Corporation, East Rochester, NY
  10. Date: Wed, 23 Dec 1992 15:44:47 GMT
  11. Lines: 31
  12.  
  13. We wrote a version of new that takes extra arguments (namely, file name
  14. and line #) so that debug information can be kept with every block of
  15. storage allocated that uses this version of new.  We are doing this to
  16. monitor storage leaks.
  17.  
  18. That's the specific situation; now, the general problem:
  19.  
  20. Writing a custom new does not allow one to write a corresponding
  21. delete, since delete cannot be overloaded (we're talking global
  22. new/delete here, not class-specific).  This means that, if any special
  23. handling is required at delete time for this custom-allocated storage,
  24. you must rewrite the standard delete.  This in turn means that no code
  25. has access anymore to the old delete, so storage allocated with the
  26. standard new could not be freed.  This means that you must customize
  27. the standard new so that delete is sure of from whence the storage
  28. came.
  29.  
  30. Whew!  Did anyone understand that?  If so, let me know if you have an
  31. easier solution (besides "use garbage collection").  Thanks.
  32.  
  33. ============================================================================
  34. Jim Heliotis                                       Voice Phone: 716-383-7410
  35. Xerox Corporation                                   FAX Phone:  716-383-7395
  36. 435 W. Commercial St.                                     Mail Stop: 803-01A
  37. East Rochester, NY 14445              Electronic Mail: JEH.ROCH803@Xerox.COM
  38. ============================================================================
  39.  
  40.  
  41.  
  42.  
  43.  
  44.