Path: utzoo!attcan!uunet!mcvax!ukc!icdoc!citycs!ba124 From: ba124@citycs.UUCP (K.A.Streater) Newsgroups: comp.lang.c++ Subject: realloc equivalent in C++ Keywords: realloc, new, delete Message-ID: <80@citycs.UUCP> Date: 17 May 89 19:42:27 GMT Organization: Computer Science, City University, London Lines: 23 In C++ there are the free storage allocators new and delete, but what about an equivalent of realloc. Have I missed it or does it not exist ? Stroustrup in his example on page 182 of C++ Programming language seems to indicate that the only way to realloc a block of storage is to create a new one, and copy all the elements before deleting the old block. i.e. in 'C': #include /* ANSI header */ int *address = (int *)malloc(size); address = (int *)realloc(address, size*2); becomes in C++: int* address = new int[size]; int* new_addr = new int[size*2]; for (int i=0; i