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