array->size = 0;
}
+LTTNG_HIDDEN
+void lttng_dynamic_array_clear(struct lttng_dynamic_array *array)
+{
+ if (array->destructor) {
+ size_t i;
+
+ for (i = 0; i < lttng_dynamic_array_get_count(array); i++) {
+ array->destructor(lttng_dynamic_array_get_element(array,
+ i));
+ }
+ }
+
+ lttng_dynamic_buffer_set_size(&array->buffer, 0);
+ array->size = 0;
+}
+
LTTNG_HIDDEN
void lttng_dynamic_pointer_array_init(
struct lttng_dynamic_pointer_array *array,
}
lttng_dynamic_array_reset(&array->array);
}
+
+LTTNG_HIDDEN
+void lttng_dynamic_pointer_array_clear(
+ struct lttng_dynamic_pointer_array *array)
+{
+ const lttng_dynamic_array_element_destructor destructor =
+ array->array.destructor;
+
+ /*
+ * Prevent the destructor from being used by the underlying
+ * dynamic array.
+ */
+ array->array.destructor = NULL;
+ if (destructor) {
+ size_t i, count = lttng_dynamic_pointer_array_get_count(array);
+
+ for (i = 0; i < count; i++) {
+ void *ptr = lttng_dynamic_pointer_array_get_pointer(
+ array, i);
+ destructor(ptr);
+ }
+ }
+ lttng_dynamic_array_clear(&array->array);
+ array->array.destructor = destructor;
+}
LTTNG_HIDDEN
void lttng_dynamic_array_reset(struct lttng_dynamic_array *array);
+/* Remove all elements from the dynamic array. */
+LTTNG_HIDDEN
+void lttng_dynamic_array_clear(struct lttng_dynamic_array *array);
/*
* Specialization of lttng_dynamic_array for pointers. This utility
void lttng_dynamic_pointer_array_reset(
struct lttng_dynamic_pointer_array *array);
+/* Remove all elements from the dynamic pointer array. */
+LTTNG_HIDDEN
+void lttng_dynamic_pointer_array_clear(
+ struct lttng_dynamic_pointer_array *array);
+
#endif /* LTTNG_DYNAMIC_ARRAY_H */