maxon::BaseArray allocation?



  • On 21/05/2014 at 20:51, xxxxxxxx wrote:

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

    ---------
    Hello Forum,
    Is there a method to test if a maxon::BaseArray has been allocated.

    maxon::BaseArray<Int32> map;
    if (!map) return false; // does not compile
    

    Or is it safe to assume that the BaseArray is always allocated?

    Thanks for your help,

    Joe



  • On 22/05/2014 at 00:06, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    <ADDRESS>
    User Information:
    Cinema 4D Version:   R15 
    Platform:   Windows  ;  
    Mac OSX  ; 
    Language(s) :    
    C++  ;

    ---------
    </ADDRESS> Hello Forum,
    Is there a method to test if a maxon::BaseArray has been allocated.

    [/DIV][DIV]maxon::BaseArray<Int32> map;[/DIV][DIV]if (!map) return false; // does not compile[/DIV][DIV]
    

    Or is it safe to assume that the BaseArray is always allocated?
    Thanks for your help,
    Joe

    You don't have to check this as the object is just created in the current scope, but no memory is allocated yet for the array.

    You've to check either
    - the return value of Append(), Insert() to see if the operation which triggered a memory allocation was successful
    - or the return value of Resize() which triggers memory allocations/releases too

    Best regards,

    Wilfried



  • On 22/05/2014 at 00:26, xxxxxxxx wrote:

    Wilfried,

    You have answered my question.  I now see in the docs that BaseArray.Append() returns a pointer and BaseArray.Resize() returns Bool.

    Thank you,

    Joe


Log in to reply