rtsp-server: 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-24 20:13:50 +00:00 committed by GStreamer Marge Bot
parent 0639f117cb
commit f5977dae15
10 changed files with 33 additions and 28 deletions

View file

@ -60,7 +60,7 @@ gst_rtsp_address_copy (GstRTSPAddress * addr)
g_return_val_if_fail (addr != NULL, NULL);
copy = g_slice_dup (GstRTSPAddress, addr);
copy = g_memdup2 (addr, sizeof (GstRTSPAddress));
/* only release to the pool when the original is freed. It's a bit
* weird but this will do for now as it avoid us to use refcounting. */
copy->pool = NULL;
@ -89,7 +89,7 @@ gst_rtsp_address_free (GstRTSPAddress * addr)
gst_rtsp_address_pool_release_address (addr->pool, addr);
}
g_free (addr->address);
g_slice_free (GstRTSPAddress, addr);
g_free (addr);
}
G_DEFINE_BOXED_TYPE (GstRTSPAddress, gst_rtsp_address,
@ -161,7 +161,7 @@ gst_rtsp_address_pool_init (GstRTSPAddressPool * pool)
static void
free_range (AddrRange * range)
{
g_slice_free (AddrRange, range);
g_free (range);
}
static void
@ -293,7 +293,7 @@ gst_rtsp_address_pool_add_range (GstRTSPAddressPool * pool,
is_multicast = ttl != 0;
range = g_slice_new0 (AddrRange);
range = g_new0 (AddrRange, 1);
if (!fill_address (min_address, min_port, &range->min, is_multicast))
goto invalid;
@ -324,7 +324,7 @@ invalid:
{
GST_ERROR_OBJECT (pool, "invalid address range %s-%s", min_address,
max_address);
g_slice_free (AddrRange, range);
g_free (range);
return FALSE;
}
}
@ -370,7 +370,7 @@ split_range (GstRTSPAddressPool * pool, AddrRange * range, guint skip_addr,
AddrRange *temp;
if (skip_addr) {
temp = g_slice_dup (AddrRange, range);
temp = g_memdup2 (range, sizeof (AddrRange));
memcpy (temp->max.bytes, temp->min.bytes, temp->min.size);
inc_address (&temp->max, skip_addr - 1);
priv->addresses = g_list_prepend (priv->addresses, temp);
@ -380,7 +380,7 @@ split_range (GstRTSPAddressPool * pool, AddrRange * range, guint skip_addr,
if (!RANGE_IS_SINGLE (range)) {
/* min and max are not the same, we have more than one address. */
temp = g_slice_dup (AddrRange, range);
temp = g_memdup2 (range, sizeof (AddrRange));
/* increment the range min address */
inc_address (&temp->min, 1);
/* and store back in pool */
@ -393,7 +393,7 @@ split_range (GstRTSPAddressPool * pool, AddrRange * range, guint skip_addr,
/* range now contains only one single address */
if (skip_port > 0) {
/* make a range with the skipped ports */
temp = g_slice_dup (AddrRange, range);
temp = g_memdup2 (range, sizeof (AddrRange));
temp->max.port = temp->min.port + skip_port - 1;
/* and store back in pool */
priv->addresses = g_list_prepend (priv->addresses, temp);
@ -404,7 +404,7 @@ split_range (GstRTSPAddressPool * pool, AddrRange * range, guint skip_addr,
/* range now contains single address with desired port number */
if (range->max.port - range->min.port + 1 > n_ports) {
/* make a range with the remaining ports */
temp = g_slice_dup (AddrRange, range);
temp = g_memdup2 (range, sizeof (AddrRange));
temp->min.port += n_ports;
/* and store back in pool */
priv->addresses = g_list_prepend (priv->addresses, temp);
@ -484,7 +484,7 @@ gst_rtsp_address_pool_acquire_address (GstRTSPAddressPool * pool,
g_mutex_unlock (&priv->lock);
if (result) {
addr = g_slice_new0 (GstRTSPAddress);
addr = g_new0 (GstRTSPAddress, 1);
addr->pool = g_object_ref (pool);
addr->address = get_address_string (&result->min);
addr->n_ports = n_ports;
@ -689,7 +689,7 @@ gst_rtsp_address_pool_reserve_address (GstRTSPAddressPool * pool,
}
if (addr_range) {
addr = g_slice_new0 (GstRTSPAddress);
addr = g_new0 (GstRTSPAddress, 1);
addr->pool = g_object_ref (pool);
addr->address = get_address_string (&addr_range->min);
addr->n_ports = n_ports;

View file

@ -1347,7 +1347,7 @@ media_unprepared (GstRTSPMedia * media, GWeakRef * ref)
static GWeakRef *
weak_ref_new (gpointer obj)
{
GWeakRef *ref = g_slice_new (GWeakRef);
GWeakRef *ref = g_new (GWeakRef, 1);
g_weak_ref_init (ref, obj);
return ref;
@ -1357,7 +1357,7 @@ static void
weak_ref_free (GWeakRef * ref)
{
g_weak_ref_clear (ref);
g_slice_free (GWeakRef, ref);
g_free (ref);
}
/**

View file

@ -3756,7 +3756,7 @@ start_prepare (GstRTSPMedia * media)
for (walk = priv->dynamic; walk; walk = g_list_next (walk)) {
GstElement *elem = walk->data;
DynPaySignalHandlers *handlers = g_slice_new (DynPaySignalHandlers);
DynPaySignalHandlers *handlers = g_new (DynPaySignalHandlers, 1);
GST_INFO ("adding callbacks for dynamic element %p", elem);
@ -4054,7 +4054,7 @@ finish_unprepare (GstRTSPMedia * media)
g_signal_handler_disconnect (G_OBJECT (elem),
handlers->no_more_pads_handler);
g_slice_free (DynPaySignalHandlers, handlers);
g_free (handlers);
}
gst_bin_remove (GST_BIN (priv->pipeline), priv->rtpbin);

View file

@ -54,7 +54,7 @@ data_item_new (gchar * path, gint len, GstRTSPMediaFactory * factory)
{
DataItem *item;
item = g_slice_alloc (sizeof (DataItem));
item = g_new (DataItem, 1);
item->path = path;
item->len = len;
item->factory = factory;
@ -69,7 +69,7 @@ data_item_free (gpointer data)
g_free (item->path);
g_object_unref (item->factory);
g_slice_free1 (sizeof (DataItem), item);
g_free (item);
}
static void

View file

@ -73,7 +73,7 @@ _gst_rtsp_permissions_free (GstRTSPPermissions * permissions)
g_ptr_array_free (impl->roles, TRUE);
g_slice_free1 (sizeof (GstRTSPPermissionsImpl), permissions);
g_free (permissions);
}
static GstRTSPPermissions *
@ -142,7 +142,7 @@ gst_rtsp_permissions_new (void)
{
GstRTSPPermissionsImpl *permissions;
permissions = g_slice_new0 (GstRTSPPermissionsImpl);
permissions = g_new0 (GstRTSPPermissionsImpl, 1);
gst_rtsp_permissions_init (permissions);
return GST_RTSP_PERMISSIONS (permissions);

View file

@ -1061,7 +1061,7 @@ free_client_context (ClientContext * ctx)
g_object_unref (ctx->client);
g_object_unref (ctx->server);
g_slice_free (ClientContext, ctx);
g_free (ctx);
return G_SOURCE_REMOVE;
}
@ -1106,7 +1106,7 @@ manage_client (GstRTSPServer * server, GstRTSPClient * client)
g_signal_emit (server, gst_rtsp_server_signals[SIGNAL_CLIENT_CONNECTED], 0,
client);
cctx = g_slice_new0 (ClientContext);
cctx = g_new0 (ClientContext, 1);
cctx->server = g_object_ref (server);
cctx->client = client;

View file

@ -1612,7 +1612,7 @@ again:
}
if (!addr) {
addr = g_slice_new0 (GstRTSPAddress);
addr = g_new0 (GstRTSPAddress, 1);
addr->port = tmp_rtp;
addr->n_ports = 2;
if (transport_settings_defined)

View file

@ -76,7 +76,7 @@ _gst_rtsp_thread_free (GstRTSPThreadImpl * impl)
g_source_unref (impl->source);
g_main_loop_unref (impl->thread.loop);
g_main_context_unref (impl->thread.context);
g_slice_free1 (sizeof (GstRTSPThreadImpl), impl);
g_free (impl);
}
static GstRTSPThread *
@ -86,7 +86,7 @@ _gst_rtsp_thread_copy (GstRTSPThreadImpl * impl)
GST_DEBUG ("copy thread %p", impl);
copy = g_slice_new0 (GstRTSPThreadImpl);
copy = g_new0 (GstRTSPThreadImpl, 1);
gst_rtsp_thread_init (copy);
copy->thread.context = g_main_context_ref (impl->thread.context);
copy->thread.loop = g_main_loop_ref (impl->thread.loop);
@ -118,7 +118,7 @@ gst_rtsp_thread_new (GstRTSPThreadType type)
{
GstRTSPThreadImpl *impl;
impl = g_slice_new0 (GstRTSPThreadImpl);
impl = g_new0 (GstRTSPThreadImpl, 1);
gst_rtsp_thread_init (impl);
impl->thread.type = type;

View file

@ -68,7 +68,7 @@ _gst_rtsp_token_free (GstRTSPToken * token)
gst_structure_set_parent_refcount (impl->structure, NULL);
gst_structure_free (impl->structure);
g_slice_free1 (sizeof (GstRTSPTokenImpl), token);
g_free (token);
}
static GstRTSPToken *
@ -79,7 +79,7 @@ _gst_rtsp_token_copy (GstRTSPTokenImpl * token)
structure = gst_structure_copy (token->structure);
copy = g_slice_new0 (GstRTSPTokenImpl);
copy = g_new0 (GstRTSPTokenImpl, 1);
gst_rtsp_token_init (copy, structure);
return (GstRTSPToken *) copy;
@ -114,7 +114,7 @@ gst_rtsp_token_new_empty (void)
s = gst_structure_new_empty ("GstRTSPToken");
g_return_val_if_fail (s != NULL, NULL);
token = g_slice_new0 (GstRTSPTokenImpl);
token = g_new0 (GstRTSPTokenImpl, 1);
gst_rtsp_token_init (token, s);
return (GstRTSPToken *) token;

View file

@ -209,6 +209,11 @@ if gst_version_nano == 0
message('Package release date: ' + release_date)
endif
glib_gio_dep = dependency('gio-2.0', version: glib_req)
if glib_gio_dep.version().version_compare('< 2.67.4')
cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
endif
configure_file(output: 'config.h', configuration: cdata)
meson.add_dist_script('scripts/gen-changelog.py', meson.project_name(), '1.20.0', meson.project_version())