Is it safe to copy a structure that contains an array, but the array is no longer the originally defined size?
My example below works, but I'm unsure if I will ever run into any memory issues.
would work the same way, since the two variables are structured and so pb knows it has to do the same thing as in copystructure, where you have to specify the structured type instead since the two pointers could simply point to some memory buffer (the destination should at least be cleared or containing valid data in some way).
So I hope is not going to make a shallow copy, but I don't why it should do it. Or am I wrong ?
would work the same way, since the two variables are structured and so pb knows it has to do the same thing as in copystructure, where you have to specify the structured type instead since the two pointers could simply point to some memory buffer (the destination should at least be cleared or containing valid data in some way).
So I hope is not going to make a shallow copy, but I don't why it should do it. Or am I wrong ?
A dynamic array in a structure will be copied correctly. All copies are deep copies.
Sorry, another quick question. Copying a structure containing a dynamic array from within another structure that is also a dynamic array would be safe, correct?
My explanation probably didn't make any since so here's some code that might help explain it a bit better.
Samuel wrote:Sorry, another quick question. Copying a structure containing a dynamic array from within another structure that is also a dynamic array would be safe, correct?