queue2: drop use of GSlice

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3695>
This commit is contained in:
Tim-Philipp Müller 2023-01-08 01:32:13 +00:00 committed by GStreamer Marge Bot
parent ed78e55bc7
commit fa55d8302b
2 changed files with 28 additions and 10 deletions

View file

@ -625,9 +625,16 @@ debug_ranges (GstQueue2 * queue)
static void
clean_ranges (GstQueue2 * queue)
{
GstQueue2Range *r, *next;
GST_DEBUG_OBJECT (queue, "clean queue ranges");
g_slice_free_chain (GstQueue2Range, queue->ranges, next);
r = queue->ranges;
while (r != NULL) {
next = r->next;
g_free (r);
r = next;
}
queue->ranges = NULL;
queue->current = NULL;
}
@ -692,7 +699,7 @@ add_range (GstQueue2 * queue, guint64 offset, gboolean update_existing)
GST_DEBUG_OBJECT (queue,
"new range %" G_GUINT64_FORMAT "-%" G_GUINT64_FORMAT, offset, offset);
range = g_slice_new0 (GstQueue2Range);
range = g_new0 (GstQueue2Range, 1);
range->offset = offset;
/* we want to write to the next location in the ring buffer */
range->rb_offset = queue->current ? queue->current->rb_writing_pos : 0;
@ -2096,7 +2103,7 @@ gst_queue2_create_write (GstQueue2 * queue, GstBuffer * buffer)
if (range_to_destroy) {
if (range_to_destroy == queue->ranges)
queue->ranges = range;
g_slice_free (GstQueue2Range, range_to_destroy);
g_free (range_to_destroy);
range_to_destroy = NULL;
}
}
@ -2146,7 +2153,7 @@ gst_queue2_create_write (GstQueue2 * queue, GstBuffer * buffer)
new_writing_pos = next->writing_pos;
do_seek = TRUE;
}
g_slice_free (GstQueue2Range, next);
g_free (next);
}
goto update_and_signal;
}

View file

@ -98,7 +98,7 @@ get_write_range (GstSparseFile * file, gsize offset)
next = next->next;
}
if (result == NULL) {
result = g_slice_new0 (GstSparseRange);
result = g_new0 (GstSparseRange, 1);
result->start = offset;
result->stop = offset;
@ -150,7 +150,7 @@ gst_sparse_file_new (void)
{
GstSparseFile *result;
result = g_slice_new0 (GstSparseFile);
result = g_new0 (GstSparseFile, 1);
result->current_pos = 0;
result->ranges = NULL;
result->n_ranges = 0;
@ -181,6 +181,17 @@ gst_sparse_file_set_fd (GstSparseFile * file, gint fd)
return file->file != NULL;
}
static void
gst_sparse_range_free_chain (GstSparseRange * r)
{
while (r != NULL) {
GstSparseRange *next = r->next;
g_free (r);
r = next;
}
}
/**
* gst_sparse_file_clear:
* @file: a #GstSparseFile
@ -192,7 +203,7 @@ gst_sparse_file_clear (GstSparseFile * file)
{
g_return_if_fail (file != NULL);
g_slice_free_chain (GstSparseRange, file->ranges, next);
gst_sparse_range_free_chain (file->ranges);
file->current_pos = 0;
file->ranges = NULL;
file->n_ranges = 0;
@ -216,8 +227,8 @@ gst_sparse_file_free (GstSparseFile * file)
fflush (file->file);
fclose (file->file);
}
g_slice_free_chain (GstSparseRange, file->ranges, next);
g_slice_free (GstSparseFile, file);
gst_sparse_range_free_chain (file->ranges);
g_free (file);
}
/**
@ -284,7 +295,7 @@ gst_sparse_file_write (GstSparseFile * file, gsize offset, gconstpointer data,
file->write_range = NULL;
if (file->read_range == next)
file->read_range = NULL;
g_slice_free (GstSparseRange, next);
g_free (next);
file->n_ranges--;
}
if (available)