1999-11-04 07:30:04 +00:00
|
|
|
<!-- ##### SECTION Title ##### -->
|
2000-04-13 01:18:41 +00:00
|
|
|
Reference Counting and Memory Mangement
|
1999-11-04 07:30:04 +00:00
|
|
|
|
|
|
|
<!-- ##### SECTION Short_Description ##### -->
|
2000-04-13 01:18:41 +00:00
|
|
|
|
|
|
|
Functions to perform reference counting and memory management on a
|
|
|
|
#GdkPixbuf.
|
1999-11-04 07:30:04 +00:00
|
|
|
|
|
|
|
<!-- ##### SECTION Long_Description ##### -->
|
1999-11-04 08:14:32 +00:00
|
|
|
<para>
|
|
|
|
#GdkPixbuf structures are reference counted. This means that
|
|
|
|
an application can share a single pixbuf among many parts of the
|
|
|
|
code. When a piece of the program needs to keep a pointer to a
|
|
|
|
pixbuf, it should add a reference to it. When it no longer needs
|
|
|
|
the pixbuf, it should subtract a reference. The pixbuf will be
|
|
|
|
destroyed when its reference count drops to zero. Newly-created
|
|
|
|
#GdkPixbuf structures start with a reference count of one.
|
|
|
|
</para>
|
1999-11-04 07:30:04 +00:00
|
|
|
|
2000-04-13 01:18:41 +00:00
|
|
|
<para>
|
|
|
|
<emphasis>Finalizing</emphasis> a pixbuf means to free its pixel
|
|
|
|
data and to free the #GdkPixbuf structure itself. Most of the
|
|
|
|
library functions that create #GdkPixbuf structures create the
|
|
|
|
pixel data by themselves and define the way it should be freed;
|
|
|
|
you do not need to worry about those. The only function that lets
|
|
|
|
you specify how to free the pixel data is
|
|
|
|
gdk_pixbuf_new_from_data(). Since you pass it a pre-allocated
|
|
|
|
pixel buffer, you must also specify a way to free that data. This
|
|
|
|
is done with a function of type #GdkPixbufDestroyNotify. When a
|
|
|
|
pixbuf created with gdk_pixbuf_new_from_data() is finalized, your
|
|
|
|
destroy notification function will be called, and it is its
|
|
|
|
responsibility to free the pixel array.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
As an extension to traditional reference counting, #GdkPixbuf
|
|
|
|
structures support defining a handler for the last unref
|
|
|
|
operation. If gdk_pixbuf_unref() is called on a #GdkPixbuf
|
|
|
|
structure that has a reference count of 1, i.e. its last
|
|
|
|
reference, then the pixbuf's last unref handler function will be
|
|
|
|
called. It is up to this function to determine whether to
|
|
|
|
finalize the pixbuf using gdk_pixbuf_finalize() or to just
|
|
|
|
continue execution. This can be used to implement a pixbuf cache
|
|
|
|
efficiently; please see the programmer's documentation for
|
|
|
|
details.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<!-- FIXME: link the last sentence above to the relevant section of
|
|
|
|
the programmer's docs.
|
|
|
|
-->
|
|
|
|
|
1999-11-04 07:30:04 +00:00
|
|
|
<!-- ##### SECTION See_Also ##### -->
|
1999-11-04 08:14:32 +00:00
|
|
|
<para>
|
2000-04-13 01:18:41 +00:00
|
|
|
#GdkPixbuf, gdk_pixbuf_new_from_data().
|
1999-11-04 08:14:32 +00:00
|
|
|
</para>
|
1999-11-04 07:30:04 +00:00
|
|
|
|