summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author江頭幸路 <koji.egashira@access-company.com>2015-04-17 20:59:17 +0900
committerBryce Harrington <bryce@osg.samsung.com>2015-04-20 17:16:18 -0700
commit040ae0ce1934ac27c6394dc74405faad34cd5913 (patch)
tree052e269e26b5e1b2a4affbd3a3f7f968f493cbfb
parent89942c6af00af8b72babeae676376f4cf8911c16 (diff)
Avoid appending an empty slot to an user data array when user_data is NULL.
Otherwise, calling cairo_set_user_data(cr, key, 0, 0) many times causes a long user data array, almost all of whose slots are empty. It leads to unnecessarily much memory consumption and long execution time of cairo_set_user_data(cr, key, 0, 0) and cairo_get_user_data(cr, key) after it. This issue probably happens since the commit http://cgit.freedesktop.org/cairo/commit/?id=9341c254a Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
-rw-r--r--src/cairo-array.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cairo-array.c b/src/cairo-array.c
index 4f3c082ff..58c9a388f 100644
--- a/src/cairo-array.c
+++ b/src/cairo-array.c
@@ -485,6 +485,9 @@ _cairo_user_data_array_set_data (cairo_user_data_array_t *array,
return CAIRO_STATUS_SUCCESS;
}
+ if (user_data == NULL)
+ return CAIRO_STATUS_SUCCESS;
+
status = _cairo_array_append (array, &new_slot);
if (unlikely (status))
return status;