chip@tct.uucp (Chip Salzenberg) (02/09/91)
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 <chip@tct.uucp>, <uunet!pdn!tct!chip> "Most of my code is written by myself. That is why so little gets done." -- Herman "HLLs will never fly" Rubin