On 03/02/2015 at 09:31, xxxxxxxx wrote:
Hi Katachi,
I investigated the code in question to see what's up with the constant pointer to a pointer of a BaseContainer, which I do find unusual in C4D's SDK. Despite what the docs vaguely imply, you shouldn't do anything but retrieve the pointer and use it to make the appropriate method calls, and let it go out of scope once it's done, meaning you shouldn't delete it. It likely crashes when internal code that expects it to still exist after you've deleted it gets called, and so never reaches the code that actually should delete it.
Long story short, a pointer to a pointer in this case, especially being const, is meant to ensure that if the BaseContainer it points to is changed to another, it can change the first pointer to it while allowing code that uses a pointer to that pointer to still correctly retrieve the new BaseContainer's address. Other than not having to delete it, I'm not sure if it provides any major benefit to you, as re-retrieving the pointer to a pointer each time is probably a good defensive programming habit.
I hope that helps!
Joey Gaspe
SDK Support Engineer