On 04/11/2016 at 10:03, xxxxxxxx wrote:
Cinema 4D Version: 13
Platform: Windows ;
Language(s) : C++ ;
Some of the C4D based pointers don't seem to be deletable by normal means.
Up to this point I've just let that go. Because null pointers don't take up much space. And I guess they get deleted when C4D closes.
But it seems technically wrong to me that there's no way to delete them. And it seems like a bad practice to leave them behind. Even though everyone seems to be doing it as a normal part of writing C4D plugins.
What mostly concerns me is creating hundreds, or thousands of these null pointers. And leaving them there for the entire time that C4D session is open.
If I wanted to. Is there some way to to delete them (BaseMaterial, BaseObject, PolygonObject, etc...)?
//Standard C++ code that deletes an empty pointer //Removes everything as expected int *myptr = nullptr; delete myptr; //<---This is standard C++ and it works //Deleting a C4D based array //Removes everything as expected GeDynamicArray<String>myarray(10); myarray = "hello"; myarray.FreeArray(); //Can't do the this because the array has not only been freed. But also myarray was deleted //myarray = "world"; //GePrint(myarray); //This is where it gets strange. There does not seem to be a way to delete some of the C4D based pointers //How do we delete a C4D based empty pointer like this? BaseObject *obj = nullptr; //delete obj; //<---Not Allowed!! BaseObject::Free(obj); //<--Nope. Frees memory. But does not delete the actual pointer if(obj == nullptr) GePrint("obj is Null. But it still exists!");