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

    Replacement for - GeAllocNC [SOLVED]

    SDK Help
    0
    3
    291
    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 05/03/2015 at 03:13, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R16 
      Platform:      
      Language(s) :     C++  ;

      ---------
      Hi Everyone,

      I'm looking through this article at the moment:

      [URL-REMOVED]

      - and I'm trying to figure out how to convert some of the code so I can get some steps closer to implementing my own licensing system. I see that there are some deprecated methods/classes in the code below and would like to know what would be the current alternative.

      The thing i'm looking at is:

      GeAllocNC

      It looks like I need to allocate some memory so I can pass a "Char \*" to the GetCString, thats the bit I can't quite figure out.

        
      `#include "c4d_md5.h"`
       
      `CHAR` `*ConvString(``const` `String& s, STRINGENCODING encoding=(STRINGENCODING)STRINGENCODING_7BIT)`
      `{`
      `  ``// Use STRINGENCODING_UTF8 as same default encoding as Python`
      `  ``LONG` `len = s.GetCStringLen(encoding);`
      `  ``CHAR` `*code = (``CHAR``* ) GeAllocNC(len+1);`
      `  ``if` `(!code) ``return` `NULL;`
       
      `  ``s.GetCString(code, len+1, encoding);`
      `  ``return` `code;`
      `}`
       
      `String GetMD5(``const` `String& p)`
      `{`
      `  ``DigestMD5 md5;`
      `  ``String key;`
      `  ``CHAR` `*c_str = NULL;`
      `  ``CHAR` `*c_tmp = NULL;`
       
      `  ``c_str = ConvString(p, STRINGENCODING_7BIT);`
      `  ``if` `(!c_str)`
      `    ``return` `String();`
       
      `  ``c_tmp = md5.get_md5hash(c_str, (unsigned ``long``)``strlen``(str));`
      `  ``if` `(!c_tmp)`
      `  ``{`
      `    ``GeFree(str);`
      `    ``return` `String();`
      `  ``}`
       
      `  ``key = c_tmp;`
      `  ``GeFree(c_str);`
      `  ``GeFree(c_tmp);`
      `  ``return` `key;`
      `}`
        
      
      

      Any help greatly appreciated.

      Thanks,

      Adam


      [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

        On 05/03/2015 at 07:06, xxxxxxxx wrote:

        Hi Adam,

        GeAllocNC()/GeFree() have been renamed to NewMem()/DeleteMem() in R15.

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

          On 05/03/2015 at 08:11, xxxxxxxx wrote:

          Amazing, thanks very much.

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