Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    GetDescEntry() [SOLVED]

    SDK Help
    0
    5
    498
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 03/02/2015 at 03:45, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   13+ 
      Platform:   Windows  ; Mac  ;  Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      Hi,

      the docs about GetDescEntry say that the assigned BaseContainer is owned by the caller. This makes me think that I must free the bc memory myself. However, trying to do so will eventually crash C4D.

      Am I misunderstanding the docs? How should the retrieved bc be handled?

      Thanks in advance

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 03/02/2015 at 10:02, xxxxxxxx wrote:

          Hi Joey,

          thanks that clears it up. But the docs should really be fixed concerning ownership. It's really misleading.

          Thanks!

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 03/02/2015 at 10:09, xxxxxxxx wrote:

            Hi Katachi,

            Thanks for confirming your question is answered, I'll close the topic as solved.  I already plan on fixing the documents to clear up the misleading wording, thanks for mentioning it anyway.

            Joey Gaspe
            SDK Support Engineer

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 03/02/2015 at 10:45, xxxxxxxx wrote:

              👍

              1 Reply Last reply Reply Quote 0
              • First post
                Last post