Re: GdkPixbuf leaks memory (continuation)



On 05/04/01 Dov Grobgeld wrote:
In continuation to my previous mail, there seems to be a problem with
the GdkPixbufTypemap. According to the perlxs tutorial a pointer
type with a destructor should be defined:

   TYPEMAP
   Foo *T_PTROBJ   

but in build/GdkPixbufTypemap we have

   Gtk::Gdk::Pixbuf        T_SimpleVal

Is there any documentation that describes how gendefs work that could
help me in figuring out how this works?

Most of the meat is in Gtk/gtk-0.99.typemap. There you will find that
types labelled with T_SimpleVal will be handled by this snippet when
used as a return value in an XS function:

$arg = sv_2mortal(newSV {[grep {s/://g,s/^GtkGdk/Gdk/,1} $ntype]}($var));

This means that in this case we get (have a look at the generated C files):

ST(0) = sv_2mortal(newSVGdkPixbuf(RETVAL));

newSVGdkPixbuf() is defined in GdkPixbuf/build/GdkPixbufDefs.c
(this file is automatically generated by gendefs):

SV * newSVGdkPixbuf(GdkPixbuf * value) {
        int n = 0;
        SV * result = newSVMiscRef(value, "Gtk::Gdk::Pixbuf", &n);
        if (n)
                gdk_pixbuf_ref(value);
        return result;
}

newSVMiscRef() will insert the C pointer in a hash table and
return a perl hash reference blessed in the "Gtk::Gdk::Pixbuf"
package. If this C pointer was not already in the hash table (n)
we increase the reference count. As I explained in another mail
this is not needed if the C object was created by the binding
(basically when the C object is returned by constructors such as
Gtk::Gdk::Pixbuf::new_from_file).

In any case, this probably only takes care of the automatic calling
of the DESTROY function, but doesn't help wit the reference count
problem.

The problem is fixed in cvs as noted in another email.

lupus

-- 
-----------------------------------------------------------------
lupus debian org                                     debian/rules
lupus ximian com                             Monkeys do it better




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