Topic: new delete where is realloc?


Author: ivin@franklin.CS.Berkeley.EDU (Ilya Vinarsky)
Date: 1995/10/20
Raw View
I could find an answer to this question in the draft std:

C++ has operators new and delete, type-safe versions of the old C functions
malloc and free.  Is there going to be a replacement for realloc?

---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]





Author: John Max Skaller <maxtal@suphys.physics.su.oz.au>
Date: 1995/10/21
Raw View
ivin@franklin.CS.Berkeley.EDU (Ilya Vinarsky) wrote:
>
>I could find an answer to this question in the draft std:
>
>C++ has operators new and delete, type-safe versions of the old C functions
>malloc and free.  Is there going to be a replacement for realloc?

     The easiest way to get this facility is
NOT to use 'new' and 'delete'; use the STL container 'vector'
instead. It reallocates automatically when you insert things.

     A closer approximation to the primitive 'realloc'
can be obtained using various STL primitives like
'uninitialised_copy' and managing your own allocations:
have a look at the source code for vector to see how it works.


--
John Max Skaller               voice: 61-2-566-2189
81 Glebe Point Rd              fax:   61-2-660-0850
GLEBE NSW 2037                 email: maxtal@suphys.physics.oz.au
AUSTRALIA                      email: skaller@maxtal.com.au
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]