Xref: utzoo comp.lang.c++:11549 comp.std.c++:583 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!sun-barr!cs.utexas.edu!uunet!pdn!tscs!tct!chip From: chip@tct.uucp (Chip Salzenberg) Newsgroups: comp.lang.c++,comp.std.c++ Subject: Re: Why no renew Message-ID: <27B2E0B5.56BB@tct.uucp> Date: 8 Feb 91 17:32:13 GMT References: <2488@bnlux0.bnl.gov> <10895@pasteur.Berkeley.EDU> Followup-To: comp.std.c++ Organization: Teltronics/TCT, Sarasota, FL Lines: 28 According to jbuck@galileo.berkeley.edu (Joe Buck): >You're free to propose a "renew" operator as an extension if >you want, but remember that new is not equivalent to malloc, >and delete is not equivalent to free; new calls a constructor >and delete calls a destructor. How about a renew that is defined only for arrays? The "delete [] p" statement requires that the size of the allocated arrray be remembered by the implementation. So renew has the information it needs to call constructors and destructors appropriately. I would like to see something like: class X { ... }; X *p = new X[1]; // calls p[0].X::X() p = renew(p, 2); // calls p[1].X::X() p = renew(p, 1); // calls p[1].X::~X() delete [] p; // calls p[0].X::~X() Remember that the current definition of "::operator new()" loses all type information, so we need some language support for this feature to work. How about it? -- Chip Salzenberg at Teltronics/TCT , "Most of my code is written by myself. That is why so little gets done." -- Herman "HLLs will never fly" Rubin