Re: realloc equivalent in C++
Posted in 1996
Charles Fiterman — — source: Informix-list mailing list archive (1991-1998)
In article <4fgir1$pri@theory.tc.cornell.edu>, Honbo Zhou <hzhou@r26n05.tc.cornell.edu> wrote: >Is there anything in C++ equvalent to realloc in C which can be used >to increase allocated memory? Can't find this even in C++ books which >talk about memory management specifically. Thanks. Honbo Realloc is one of C's mistakes. It assimes that the realloc()ed memory can be moved bitwise. In C++ this is often false. C++ objects often contain self pointers or are the targets of numerous outside pointers. So you need a realloc for each object type that invokes destructors and constructors to move things. It might be doable with templates.