- if (idx < last_item_index) {
- /* idx is before last_item_index, move data towards zero */
- memmove (array->array + elt_size * idx,
- array->array + elt_size * (idx + 1),
- (last_item_index - idx) * elt_size);
+ if (actual_idx < last_item_index) {
+ /* clear idx if needed */
+ gst_queue_array_clear_idx (array, idx);
+
+ /* actual_idx is before last_item_index, move data towards zero */
+ memmove (array->array + elt_size * actual_idx,
+ array->array + elt_size * (actual_idx + 1),
+ (last_item_index - actual_idx) * elt_size);