gnash-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-dev] Memory allocation model?


From: Michael Meier
Subject: [Gnash-dev] Memory allocation model?
Date: Tue, 21 Nov 2006 17:25:35 +0100
User-agent: Debian Thunderbird 1.0.2 (X11/20060926)

Hello

Is there any documentation about the memory management model in gnash?

Right at the moment I don't understand when I have to take care of
deleting an object like an as_value or an object inherited from
as_object and when I don't have to.

e.g. following code:
(as I am working on the split method in server/asobj/String.cpp)
        
        tu_string_as_object* this_string_ptr = (tu_string_as_object*) 
fn.this_ptr;
        
        as_array_object* array = new as_array_object();
        as_value* val = new as_value();
        
        val->set_tu_string(this_string_ptr->m_string);
        
        tu_string *tustr = new tu_string(this_string_ptr->m_string);
                
                
        val->set_tu_string(*tustr);
        array->push(*val);
                
        fn.result->set_as_object(array);
        return;


I am allocating a new as_array_object, a new as_value and a new
tu_string. Then I am setting the AS value of val to the string stored in
*tustr. This is not copying the string, just pointing to it? Or is it
already incrementing a reference count - if reference counts exist.
Then I am pushing the as_value onto the array - is this also only
creating a pointer/reference?
Finally I set the result and return from the function.

Is this code correct? Is there a need to do something with the objects
pointed to by array, val and tustr or will they be taken care of by
other code?


cheers,
Michael




reply via email to

[Prev in Thread] Current Thread [Next in Thread]