summaryrefslogtreecommitdiff
path: root/src/cairo-array.c
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2023-02-19 21:10:58 +1030
committerAdrian Johnson <ajohnson@redneon.com>2023-04-18 18:27:12 +0930
commitb53b48116e610d61cdf630c24a11b59a18345e16 (patch)
tree3bc8f3410e795ce81c1408b9d7f3a217033d29ba /src/cairo-array.c
parente7ed40a71dac04cb4c608b409b04577d01f08454 (diff)
downloadcairo-b53b48116e610d61cdf630c24a11b59a18345e16.tar.gz
Make cairo_tag_begin/end work correctly in groups
Fixes #508
Diffstat (limited to 'src/cairo-array.c')
-rw-r--r--src/cairo-array.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/cairo-array.c b/src/cairo-array.c
index 1c91b7c73..064b63f29 100644
--- a/src/cairo-array.c
+++ b/src/cairo-array.c
@@ -542,3 +542,39 @@ _cairo_array_sort (const cairo_array_t *array, int (*compar)(const void *, const
{
qsort (array->elements, array->num_elements, array->element_size, compar);
}
+
+/**
+ * _cairo_array_pop_element:
+ * @array: a #cairo_array_t
+ * Returns: A TRUE if element successfully popped, FALSE if the array is empty.
+ *
+ * Copy the last element out of the array from index @index into the
+ * location pointed to by @dst and remove the element from the array.
+ **/
+cairo_bool_t
+_cairo_array_pop_element (cairo_array_t *array, void *dst)
+{
+ if (array->num_elements > 0) {
+ _cairo_array_copy_element (array, array->num_elements - 1, dst);
+ array->num_elements--;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * _cairo_array_top_element:
+ * @array: a #cairo_array_t
+ * Returns: A pointer to the last of object or NULL if array is empty.
+ *
+ * Get the pointer to the last element of of the array.
+ **/
+void *
+_cairo_array_last_element (cairo_array_t *array)
+{
+ if (array->num_elements > 0)
+ return _cairo_array_index (array, array->num_elements - 1);
+
+ return NULL;
+}