object: avoid creating a new entry for NULL data

If setting NULL user data via cogl_object_set_user_data() and we fail to
find an entry for the given key then bail out before potentially
allocating a new entry since setting NULL data is documented to
effectively delete an entry.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
Robert Bragg 2012-02-19 22:48:51 +00:00
parent 31097c0488
commit ed06d0ca01

View File

@ -190,6 +190,12 @@ _cogl_object_set_user_data (CoglObject *object,
}
else
{
/* NB: Setting a value of NULL is documented to delete the
* corresponding entry so we can return immediately in this
* case. */
if (user_data == NULL)
return;
if (G_LIKELY (object->n_user_data_entries <
COGL_OBJECT_N_PRE_ALLOCATED_USER_DATA_ENTRIES))
entry = &object->user_data_entry[object->n_user_data_entries++];