Dejan Jovanović wrote:
Is it reasonable to assume that plain copying of (the cl_I) data to increase memory size (via realloc), or when doing garbage-collection, will not break anything?
Here you need to be careful. Moving a cl_I from one place in memory to another address is not a problem. But when you use realloc to grow an array of cl_I, say, from 10 to 15 elements, the last 5 elements will not be initialized. Accessing these elements may crash. In order to initialize these elements, you need to call the no-argument constructor cl_I::cl_I() on them (via a placement-new expression). And symmetrically, before you shrink an array of 15 elements to 10 elements, you need to call the destructor cl_I::~cl_I() on the 5 elements that will be freed. Otherwise you will have a memory leak. You can avoid these complexities by using the C++ memory allocators new[]/ delete[] instead of the C memory allocator malloc/free. Bruno