home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11552 < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.9 KB  |  46 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!timbuk.cray.com!hemlock.cray.com!de
  3. From: de@cray.com (Duane Eitzen)
  4. Subject: Re: Renew?
  5. Message-ID: <1992Jul25.151227.8156@hemlock.cray.com>
  6. Lines: 35
  7. Organization: Cray Research, Inc.
  8. References: <1992Jul5.002414.390@frumious.uucp> <THOTH.92Jul25110048@wave.cis.ufl.edu> <23315@alice.att.com>
  9. Date: 25 Jul 92 15:12:27 CDT
  10.  
  11. In article <23315@alice.att.com> ark@alice.UUCP () writes:
  12. >In article <THOTH.92Jul25110048@wave.cis.ufl.edu> thoth@wave.cis.ufl.edu (Robert Forsman) writes:
  13. >
  14. >> The absence of an analog for realloc is one of my MAJOR gripes with
  15. >> C++
  16. >
  17. >So make a proposal.  I and several other people have thought about
  18. >it from time to time but so far I have not seen a proposal I like.
  19. >
  20. >There is also the problem that it is potentially very difficult to
  21. >implement in a C-based environment if it is required to use realloc.
  22. >The trouble is that you can't tell whether realloc will move something
  23. >until after it's too late.
  24. >
  25.  
  26. To restate the problem: if your C++ is actually just a C++ to C translator,
  27. you can't use realloc() in your implementation of renew.
  28.  
  29. This is true. Two ways around this: one is to implement your own
  30. memory management (difficult, as you say). The other is to take
  31. advantage of the fact that renew can do the move every time and still
  32. adhere to the specification (although not providing the implied
  33. performance gains). With this approach, renew can be implemented with
  34. only malloc().
  35.  
  36. So in the worst case, renew would just be short hand for a new, a bunch
  37. of copies and a delete. With a good compiler and a little luck, it
  38. could provide significant performance gains. This is all that realloc()
  39. claims to be now. And I like realloc.
  40.  
  41. On the topic of submitting a proposal: how does one do this? How
  42. much time should one expect to spend doing it? What percentage of
  43. external proposals are successful?
  44.  
  45. Duane.
  46.