shm: drop use of GSlice allocator

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3784>
This commit is contained in:
Tim-Philipp Müller 2023-01-25 01:11:14 +00:00 committed by GStreamer Marge Bot
parent 3f94d7ec37
commit 35405de344
3 changed files with 14 additions and 14 deletions

View file

@ -175,7 +175,7 @@ gst_shm_sink_allocator_free (GstAllocator * allocator, GstMemory * mem)
} }
gst_object_unref (mem->allocator); gst_object_unref (mem->allocator);
g_slice_free (GstShmSinkMemory, mymem); g_free (mymem);
} }
static gpointer static gpointer
@ -206,7 +206,7 @@ gst_shm_sink_allocator_mem_share (GstMemory * mem, gssize offset, gssize size)
if (size == -1) if (size == -1)
size = mem->size - offset; size = mem->size - offset;
mysub = g_slice_new0 (GstShmSinkMemory); mysub = g_new0 (GstShmSinkMemory, 1);
/* the shared memory is always readonly */ /* the shared memory is always readonly */
gst_memory_init (GST_MEMORY_CAST (mysub), GST_MINI_OBJECT_FLAGS (parent) | gst_memory_init (GST_MEMORY_CAST (mysub), GST_MINI_OBJECT_FLAGS (parent) |
GST_MINI_OBJECT_FLAG_LOCK_READONLY, gst_object_ref (mem->allocator), GST_MINI_OBJECT_FLAG_LOCK_READONLY, gst_object_ref (mem->allocator),
@ -271,7 +271,7 @@ gst_shm_sink_allocator_alloc_locked (GstShmSinkAllocator * self, gsize size,
"Allocated block %p with %" G_GSIZE_FORMAT " bytes at %p", block, size, "Allocated block %p with %" G_GSIZE_FORMAT " bytes at %p", block, size,
sp_writer_block_get_buf (block)); sp_writer_block_get_buf (block));
mymem = g_slice_new0 (GstShmSinkMemory); mymem = g_new0 (GstShmSinkMemory, 1);
memory = GST_MEMORY_CAST (mymem); memory = GST_MEMORY_CAST (mymem);
mymem->data = sp_writer_block_get_buf (block); mymem->data = sp_writer_block_get_buf (block);
mymem->sink = gst_object_ref (self->sink); mymem->sink = gst_object_ref (self->sink);
@ -630,7 +630,7 @@ gst_shm_sink_stop (GstBaseSink * bsink)
(sp_buffer_free_callback) gst_buffer_unref, NULL); (sp_buffer_free_callback) gst_buffer_unref, NULL);
g_signal_emit (self, signals[SIGNAL_CLIENT_DISCONNECTED], 0, g_signal_emit (self, signals[SIGNAL_CLIENT_DISCONNECTED], 0,
client->pollfd.fd); client->pollfd.fd);
g_slice_free (struct GstShmClient, client); g_free (client);
} }
gst_poll_free (self->poll); gst_poll_free (self->poll);
@ -877,7 +877,7 @@ pollthread_func (gpointer data)
return NULL; return NULL;
} }
gclient = g_slice_new (struct GstShmClient); gclient = g_new (struct GstShmClient, 1);
gclient->client = client; gclient->client = client;
gst_poll_fd_init (&gclient->pollfd); gst_poll_fd_init (&gclient->pollfd);
gclient->pollfd.fd = sp_writer_get_client_fd (client); gclient->pollfd.fd = sp_writer_get_client_fd (client);
@ -943,7 +943,7 @@ pollthread_func (gpointer data)
g_signal_emit (self, signals[SIGNAL_CLIENT_DISCONNECTED], 0, g_signal_emit (self, signals[SIGNAL_CLIENT_DISCONNECTED], 0,
gclient->pollfd.fd); gclient->pollfd.fd);
g_slice_free (struct GstShmClient, gclient); g_free (gclient);
goto again; goto again;
} }

View file

@ -233,7 +233,7 @@ gst_shm_src_start_reading (GstShmSrc * self)
return FALSE; return FALSE;
} }
gstpipe = g_slice_new0 (GstShmPipe); gstpipe = g_new0 (GstShmPipe, 1);
gstpipe->use_count = 1; gstpipe->use_count = 1;
gstpipe->src = gst_object_ref (self); gstpipe->src = gst_object_ref (self);
@ -316,7 +316,7 @@ free_buffer (gpointer data)
gst_shm_pipe_dec (gsb->pipe); gst_shm_pipe_dec (gsb->pipe);
g_slice_free (struct GstShmBuffer, gsb); g_free (gsb);
} }
static GstFlowReturn static GstFlowReturn
@ -380,7 +380,7 @@ gst_shm_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
GST_LOG_OBJECT (self, "Got buffer %p of size %d", buf, rv); GST_LOG_OBJECT (self, "Got buffer %p of size %d", buf, rv);
gsb = g_slice_new0 (struct GstShmBuffer); gsb = g_new0 (struct GstShmBuffer, 1);
gsb->buf = buf; gsb->buf = buf;
gsb->pipe = pipe; gsb->pipe = pipe;
@ -476,5 +476,5 @@ gst_shm_pipe_dec (GstShmPipe * pipe)
GST_OBJECT_UNLOCK (pipe->src); GST_OBJECT_UNLOCK (pipe->src);
gst_object_unref (pipe->src); gst_object_unref (pipe->src);
g_slice_free (GstShmPipe, pipe); g_free (pipe);
} }

View file

@ -30,11 +30,11 @@
#ifdef SHM_PIPE_USE_GLIB #ifdef SHM_PIPE_USE_GLIB
#include <glib.h> #include <glib.h>
#define spalloc_new(type) g_slice_new (type) #define spalloc_new(type) g_new (type,1)
#define spalloc_alloc(size) g_slice_alloc (size) #define spalloc_alloc(size) g_malloc (size)
#define spalloc_free(type, buf) g_slice_free (type, buf) #define spalloc_free(type, buf) g_free (buf)
#define spalloc_free1(size, buf) g_slice_free1 (size, buf) #define spalloc_free1(size, buf) g_free (buf)
#else #else