This allows to track the number of objects allocated by Cogl. The
results are displayed on the standard output by calling :
cogl_debug_print_instances ();
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
Signed-off-by: Neil Roberts <neil@linux.intel.com>
This adds an internal alternative to cogl_object_set_user_data that also
passes an instance pointer to destroy notify callbacks.
When setting private data on a CoglObject it's often desirable to know
the instance being destroyed when we are being notified to free the
private data due to the object being freed. The typical solution to this
is to track a pointer to the instance in the private data itself so it
can be identified but that usually requires an extra micro allocation
for the private data that could have been avoided if only the callback
were given an instance pointer.
The new internal _cogl_object_set_user_data passes the instance pointer
as a second argument which means it is ABI compatible for us to layer
the public version on top of this internal function.
A non-static function named cogl_object_get_type was inadvertently added
during the addition of the CoglObject base type, but there is no public
prototype in the headers and it's only referenced inside cogl-object.c
to implement cogl_handle_get_type() for compatibility. This removes the
function since we don't want to commit to CoglObject always simply being
a boxed type. In the future we may want to register hierarchical
GTypeInstance based types.
If there is private data associated with a CoglObject then there may be
a user_data_array that needs to be freed. The code was mistakenly
freeing the array inside the loop that was actually iterating over the
user data array notifying the objects destruction instead of waiting
until all the data entries had been destroyed.
This provides a mechanism for associating private data with any
CoglObject. We expect Clutter will use this to associate weak materials
with normal materials.