Re: realloc equivalent in C++
Posted in 1996
Topics: General Discussion
Steve Teale (steve@eclipse.net) wrote on 14.02.96 about "Re: realloc equivalent in C++": > >> > 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 > >> Yes. realloc. > > >Yeah, but mixing C++'s new and the old C type alloc, realloc, etc is > >VERY bad! So don't do it! > > Many implementations of operator new and operator delete will use the > existing C functions, or at least the same underlying memory > management code. Yes, but MANY does not mean ALL. new MAY call malloc internally but the compiler maker is free to choose a completely different storage allocation sheme for objects. And there was a good reason why there is no built in realloc for memory you allocated with new. malloc can't handle objects because it can't deal with contructors and the like. Doing a reallocation for built-in types is easy, but doing the realloc for unknown objects would be very difficult ! And: why do you cross-post this to so many inapropriate groups ? Follow up set to comp.lang.c++ --- Take a look at ... Walter Sommergruber The Software Site email: wsog@softsite.co.at http://www.softsite.co.at/softsite/