Subj : Re: realloc() issue on C++ To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Sun Mar 20 2005 08:15 pm If what you are calling 'objects' are C style items then in C++ you can continue to legally use malloc, realloc and free with them. If you must use new [] then no equivalent to realloc is provided. I am confused about what you wrote. You say that you 'converted' from C and in doing so changed to new [] and delete []. However you say that you did it so that the constructors and destructors would be called. C has no constructors or destructors so nothing to call. If in your conversion you added constructors and destructors then it seems that you could add a static member variable to each of the structures or classes to count the number of allocated items and therefore have the information to develop your own equivalent to realloc. However that both requires much more work and a great deal of debugging to even approach the use of the simple, already debugged and optimized vector class. If it were my code I'd either use malloc, realloc and free or I'd use vector. As for having 15,000 lines of C++ code converted from C, that might not really be that much work. How many of the lines do a realloc? .. Ed > José Mauro wrote in message > news:423ddfc7@newsgroups.borland.com... > Yes, std::vector is the clean solution for a new code. > > However, my problem is practical. I have 15000 lines of ANSI C code, > converted to C++ and making use of templates to apply the algorithm > in > custom data types. The original malloc() and free() calls were > converted > to new [] and delete [], to guarantee constructors and destructors > calls > for each array element. For the realloc() calls, i need a way to > expand > the memory, now obtained through the new [] operator. > > Someone know a "quick & dirty" way to solve this problem? .