registry: 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-07 19:20:41 +00:00 committed by GStreamer Marge Bot
parent e675519a2c
commit ade83c8355
7 changed files with 41 additions and 41 deletions

View file

@ -163,7 +163,7 @@ gst_element_factory_cleanup (GstElementFactory * factory)
GstStaticPadTemplate *templ = item->data; GstStaticPadTemplate *templ = item->data;
gst_static_caps_cleanup (&templ->static_caps); gst_static_caps_cleanup (&templ->static_caps);
g_slice_free (GstStaticPadTemplate, templ); g_free (templ);
} }
g_list_free (factory->staticpadtemplates); g_list_free (factory->staticpadtemplates);
factory->staticpadtemplates = NULL; factory->staticpadtemplates = NULL;
@ -257,7 +257,7 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
GstStaticPadTemplate *newt; GstStaticPadTemplate *newt;
gchar *caps_string = gst_caps_to_string (templ->caps); gchar *caps_string = gst_caps_to_string (templ->caps);
newt = g_slice_new (GstStaticPadTemplate); newt = g_new (GstStaticPadTemplate, 1);
newt->name_template = g_intern_string (templ->name_template); newt->name_template = g_intern_string (templ->name_template);
newt->direction = templ->direction; newt->direction = templ->direction;
newt->presence = templ->presence; newt->presence = templ->presence;

View file

@ -1881,7 +1881,7 @@ gst_plugin_ext_dep_free (GstPluginDep * dep)
g_strfreev (dep->env_vars); g_strfreev (dep->env_vars);
g_strfreev (dep->paths); g_strfreev (dep->paths);
g_strfreev (dep->names); g_strfreev (dep->names);
g_slice_free (GstPluginDep, dep); g_free (dep);
} }
static gboolean static gboolean
@ -1960,7 +1960,7 @@ gst_plugin_add_dependency (GstPlugin * plugin, const gchar ** env_vars,
} }
} }
dep = g_slice_new (GstPluginDep); dep = g_new (GstPluginDep, 1);
dep->env_vars = g_strdupv ((gchar **) env_vars); dep->env_vars = g_strdupv ((gchar **) env_vars);
dep->paths = g_strdupv ((gchar **) paths); dep->paths = g_strdupv ((gchar **) paths);

View file

@ -147,7 +147,7 @@ static gboolean plugin_loader_sync_with_child (GstPluginLoader * l);
static GstPluginLoader * static GstPluginLoader *
plugin_loader_new (GstRegistry * registry) plugin_loader_new (GstRegistry * registry)
{ {
GstPluginLoader *l = g_slice_new0 (GstPluginLoader); GstPluginLoader *l = g_new0 (GstPluginLoader, 1);
if (registry) if (registry)
l->registry = gst_object_ref (registry); l->registry = gst_object_ref (registry);
@ -211,12 +211,12 @@ plugin_loader_free (GstPluginLoader * loader)
while (cur) { while (cur) {
PendingPluginEntry *entry = (PendingPluginEntry *) (cur->data); PendingPluginEntry *entry = (PendingPluginEntry *) (cur->data);
g_free (entry->filename); g_free (entry->filename);
g_slice_free (PendingPluginEntry, entry); g_free (entry);
cur = g_list_delete_link (cur, cur); cur = g_list_delete_link (cur, cur);
} }
g_slice_free (GstPluginLoader, loader); g_free (loader);
return got_plugin_details; return got_plugin_details;
} }
@ -235,7 +235,7 @@ plugin_loader_load (GstPluginLoader * loader, const gchar * filename,
GST_LOG_OBJECT (loader->registry, GST_LOG_OBJECT (loader->registry,
"Sending file %s to child. tag %u", filename, loader->next_tag); "Sending file %s to child. tag %u", filename, loader->next_tag);
entry = g_slice_new (PendingPluginEntry); entry = g_new (PendingPluginEntry, 1);
entry->tag = loader->next_tag++; entry->tag = loader->next_tag++;
entry->filename = g_strdup (filename); entry->filename = g_strdup (filename);
entry->file_size = file_size; entry->file_size = file_size;
@ -283,7 +283,7 @@ restart:
/* Now remove this crashy plugin from the head of the list */ /* Now remove this crashy plugin from the head of the list */
l->pending_plugins = g_list_delete_link (cur, cur); l->pending_plugins = g_list_delete_link (cur, cur);
g_free (entry->filename); g_free (entry->filename);
g_slice_free (PendingPluginEntry, entry); g_free (entry);
if (l->pending_plugins == NULL) if (l->pending_plugins == NULL)
l->pending_plugins_tail = NULL; l->pending_plugins_tail = NULL;
if (!gst_plugin_loader_spawn (l)) if (!gst_plugin_loader_spawn (l))
@ -982,7 +982,7 @@ handle_rx_packet (GstPluginLoader * l,
} else { } else {
cur = g_list_delete_link (cur, cur); cur = g_list_delete_link (cur, cur);
g_free (e->filename); g_free (e->filename);
g_slice_free (PendingPluginEntry, e); g_free (e);
} }
} }
@ -1016,7 +1016,7 @@ handle_rx_packet (GstPluginLoader * l,
if (entry != NULL) { if (entry != NULL) {
g_free (entry->filename); g_free (entry->filename);
g_slice_free (PendingPluginEntry, entry); g_free (entry);
} }
/* Remove the plugin entry we just loaded */ /* Remove the plugin entry we just loaded */

View file

@ -103,7 +103,7 @@ typedef struct BinaryRegistryCache
static BinaryRegistryCache * static BinaryRegistryCache *
gst_registry_binary_cache_init (GstRegistry * registry, const char *location) gst_registry_binary_cache_init (GstRegistry * registry, const char *location)
{ {
BinaryRegistryCache *cache = g_slice_new0 (BinaryRegistryCache); BinaryRegistryCache *cache = g_new0 (BinaryRegistryCache, 1);
cache->location = location; cache->location = location;
return cache; return cache;
} }
@ -157,7 +157,7 @@ gst_registry_binary_cache_finish (BinaryRegistryCache * cache, gboolean success)
} }
g_free (cache->mem); g_free (cache->mem);
g_slice_free (BinaryRegistryCache, cache); g_free (cache);
return ret; return ret;
} }
@ -173,7 +173,7 @@ typedef struct BinaryRegistryCache
static BinaryRegistryCache * static BinaryRegistryCache *
gst_registry_binary_cache_init (GstRegistry * registry, const char *location) gst_registry_binary_cache_init (GstRegistry * registry, const char *location)
{ {
BinaryRegistryCache *cache = g_slice_new0 (BinaryRegistryCache); BinaryRegistryCache *cache = g_new0 (BinaryRegistryCache, 1);
int fd; int fd;
cache->location = location; cache->location = location;
@ -203,7 +203,7 @@ gst_registry_binary_cache_init (GstRegistry * registry, const char *location)
if (fd == -1) { if (fd == -1) {
GST_DEBUG ("g_mkstemp() failed: %s", g_strerror (errno)); GST_DEBUG ("g_mkstemp() failed: %s", g_strerror (errno));
g_free (cache->tmp_location); g_free (cache->tmp_location);
g_slice_free (BinaryRegistryCache, cache); g_free (cache);
return NULL; return NULL;
} }
@ -218,7 +218,7 @@ gst_registry_binary_cache_init (GstRegistry * registry, const char *location)
GST_DEBUG ("fdopen() failed: %s", g_strerror (errno)); GST_DEBUG ("fdopen() failed: %s", g_strerror (errno));
close (fd); close (fd);
g_free (cache->tmp_location); g_free (cache->tmp_location);
g_slice_free (BinaryRegistryCache, cache); g_free (cache);
return NULL; return NULL;
} }
@ -310,7 +310,7 @@ gst_registry_binary_cache_finish (BinaryRegistryCache * cache, gboolean success)
} }
g_free (cache->tmp_location); g_free (cache->tmp_location);
g_slice_free (BinaryRegistryCache, cache); g_free (cache);
GST_INFO ("Wrote binary registry cache"); GST_INFO ("Wrote binary registry cache");
return TRUE; return TRUE;
@ -324,7 +324,7 @@ fail_after_fclose:
{ {
g_unlink (cache->tmp_location); g_unlink (cache->tmp_location);
g_free (cache->tmp_location); g_free (cache->tmp_location);
g_slice_free (BinaryRegistryCache, cache); g_free (cache);
return FALSE; return FALSE;
} }
fflush_failed: fflush_failed:

View file

@ -119,9 +119,9 @@ _priv_gst_registry_chunk_free (GstRegistryChunk * chunk)
if ((chunk->flags & GST_REGISTRY_CHUNK_FLAG_MALLOC)) if ((chunk->flags & GST_REGISTRY_CHUNK_FLAG_MALLOC))
g_free (chunk->data); g_free (chunk->data);
else else
g_slice_free1 (chunk->size, chunk->data); g_free (chunk->data);
} }
g_slice_free (GstRegistryChunk, chunk); g_free (chunk);
} }
/* /*
@ -141,7 +141,7 @@ gst_registry_chunks_save_const_string (GList ** list, const gchar * str)
str = ""; str = "";
} }
chunk = g_slice_new (GstRegistryChunk); chunk = g_new (GstRegistryChunk, 1);
chunk->data = (gpointer) str; chunk->data = (gpointer) str;
chunk->size = strlen ((gchar *) chunk->data) + 1; chunk->size = strlen ((gchar *) chunk->data) + 1;
chunk->flags = GST_REGISTRY_CHUNK_FLAG_CONST; chunk->flags = GST_REGISTRY_CHUNK_FLAG_CONST;
@ -162,7 +162,7 @@ gst_registry_chunks_save_string (GList ** list, gchar * str)
{ {
GstRegistryChunk *chunk; GstRegistryChunk *chunk;
chunk = g_slice_new (GstRegistryChunk); chunk = g_new (GstRegistryChunk, 1);
chunk->data = str; chunk->data = str;
chunk->size = strlen ((gchar *) chunk->data) + 1; chunk->size = strlen ((gchar *) chunk->data) + 1;
chunk->flags = GST_REGISTRY_CHUNK_FLAG_MALLOC; chunk->flags = GST_REGISTRY_CHUNK_FLAG_MALLOC;
@ -183,7 +183,7 @@ gst_registry_chunks_make_data (gpointer data, gulong size)
{ {
GstRegistryChunk *chunk; GstRegistryChunk *chunk;
chunk = g_slice_new (GstRegistryChunk); chunk = g_new (GstRegistryChunk, 1);
chunk->data = data; chunk->data = data;
chunk->size = size; chunk->size = size;
chunk->flags = GST_REGISTRY_CHUNK_FLAG_NONE; chunk->flags = GST_REGISTRY_CHUNK_FLAG_NONE;
@ -206,7 +206,7 @@ gst_registry_chunks_save_pad_template (GList ** list,
GstRegistryChunkPadTemplate *pt; GstRegistryChunkPadTemplate *pt;
GstRegistryChunk *chk; GstRegistryChunk *chk;
pt = g_slice_new (GstRegistryChunkPadTemplate); pt = g_new (GstRegistryChunkPadTemplate, 1);
chk = chk =
gst_registry_chunks_make_data (pt, sizeof (GstRegistryChunkPadTemplate)); gst_registry_chunks_make_data (pt, sizeof (GstRegistryChunkPadTemplate));
@ -251,7 +251,7 @@ gst_registry_chunks_save_feature (GList ** list, GstPluginFeature * feature)
/* Initialize with zeroes because of struct padding and /* Initialize with zeroes because of struct padding and
* valgrind complaining about copying uninitialized memory * valgrind complaining about copying uninitialized memory
*/ */
ef = g_slice_new0 (GstRegistryChunkElementFactory); ef = g_new0 (GstRegistryChunkElementFactory, 1);
pf_size = sizeof (GstRegistryChunkElementFactory); pf_size = sizeof (GstRegistryChunkElementFactory);
chk = gst_registry_chunks_make_data (ef, pf_size); chk = gst_registry_chunks_make_data (ef, pf_size);
ef->npadtemplates = ef->ninterfaces = ef->nuriprotocols = 0; ef->npadtemplates = ef->ninterfaces = ef->nuriprotocols = 0;
@ -311,7 +311,7 @@ gst_registry_chunks_save_feature (GList ** list, GstPluginFeature * feature)
/* Initialize with zeroes because of struct padding and /* Initialize with zeroes because of struct padding and
* valgrind complaining about copying uninitialized memory * valgrind complaining about copying uninitialized memory
*/ */
tff = g_slice_new0 (GstRegistryChunkTypeFindFactory); tff = g_new0 (GstRegistryChunkTypeFindFactory, 1);
pf_size = sizeof (GstRegistryChunkTypeFindFactory); pf_size = sizeof (GstRegistryChunkTypeFindFactory);
chk = gst_registry_chunks_make_data (tff, pf_size); chk = gst_registry_chunks_make_data (tff, pf_size);
tff->nextensions = 0; tff->nextensions = 0;
@ -345,7 +345,7 @@ gst_registry_chunks_save_feature (GList ** list, GstPluginFeature * feature)
/* Initialize with zeroes because of struct padding and /* Initialize with zeroes because of struct padding and
* valgrind complaining about copying uninitialized memory * valgrind complaining about copying uninitialized memory
*/ */
tff = g_slice_new0 (GstRegistryChunkDeviceProviderFactory); tff = g_new0 (GstRegistryChunkDeviceProviderFactory, 1);
chk = chk =
gst_registry_chunks_make_data (tff, gst_registry_chunks_make_data (tff,
sizeof (GstRegistryChunkDeviceProviderFactory)); sizeof (GstRegistryChunkDeviceProviderFactory));
@ -359,13 +359,13 @@ gst_registry_chunks_save_feature (GList ** list, GstPluginFeature * feature)
/* Initialize with zeroes because of struct padding and /* Initialize with zeroes because of struct padding and
* valgrind complaining about copying uninitialized memory * valgrind complaining about copying uninitialized memory
*/ */
pf = g_slice_new0 (GstRegistryChunkPluginFeature); pf = g_new0 (GstRegistryChunkPluginFeature, 1);
pf_size = sizeof (GstRegistryChunkPluginFeature); pf_size = sizeof (GstRegistryChunkPluginFeature);
chk = gst_registry_chunks_make_data (pf, pf_size); chk = gst_registry_chunks_make_data (pf, pf_size);
} else if (GST_IS_DYNAMIC_TYPE_FACTORY (feature)) { } else if (GST_IS_DYNAMIC_TYPE_FACTORY (feature)) {
GstRegistryChunkDynamicTypeFactory *tmp; GstRegistryChunkDynamicTypeFactory *tmp;
tmp = g_slice_new0 (GstRegistryChunkDynamicTypeFactory); tmp = g_new0 (GstRegistryChunkDynamicTypeFactory, 1);
chk = chk =
gst_registry_chunks_make_data (tmp, gst_registry_chunks_make_data (tmp,
sizeof (GstRegistryChunkDynamicTypeFactory)); sizeof (GstRegistryChunkDynamicTypeFactory));
@ -387,8 +387,8 @@ gst_registry_chunks_save_feature (GList ** list, GstPluginFeature * feature)
/* Errors */ /* Errors */
fail: fail:
g_slice_free (GstRegistryChunk, chk); g_free (chk);
g_slice_free1 (pf_size, pf); g_free (pf);
return FALSE; return FALSE;
} }
@ -399,7 +399,7 @@ gst_registry_chunks_save_plugin_dep (GList ** list, GstPluginDep * dep)
GstRegistryChunk *chk; GstRegistryChunk *chk;
gchar **s; gchar **s;
ed = g_slice_new (GstRegistryChunkDep); ed = g_new (GstRegistryChunkDep, 1);
chk = gst_registry_chunks_make_data (ed, sizeof (GstRegistryChunkDep)); chk = gst_registry_chunks_make_data (ed, sizeof (GstRegistryChunkDep));
ed->flags = dep->flags; ed->flags = dep->flags;
@ -441,7 +441,7 @@ _priv_gst_registry_chunks_save_plugin (GList ** list, GstRegistry * registry,
GList *plugin_features = NULL; GList *plugin_features = NULL;
GList *walk; GList *walk;
pe = g_slice_new (GstRegistryChunkPluginElement); pe = g_new (GstRegistryChunkPluginElement, 1);
chk = chk =
gst_registry_chunks_make_data (pe, gst_registry_chunks_make_data (pe,
sizeof (GstRegistryChunkPluginElement)); sizeof (GstRegistryChunkPluginElement));
@ -502,8 +502,8 @@ _priv_gst_registry_chunks_save_plugin (GList ** list, GstRegistry * registry,
/* Errors */ /* Errors */
fail: fail:
gst_plugin_feature_list_free (plugin_features); gst_plugin_feature_list_free (plugin_features);
g_slice_free (GstRegistryChunk, chk); g_free (chk);
g_slice_free (GstRegistryChunkPluginElement, pe); g_free (pe);
return FALSE; return FALSE;
} }
@ -527,7 +527,7 @@ gst_registry_chunks_load_pad_template (GstElementFactory * factory, gchar ** in,
*in); *in);
unpack_element (*in, pt, GstRegistryChunkPadTemplate, end, fail); unpack_element (*in, pt, GstRegistryChunkPadTemplate, end, fail);
template = g_slice_new (GstStaticPadTemplate); template = g_new (GstStaticPadTemplate, 1);
template->presence = pt->presence; template->presence = pt->presence;
template->direction = (GstPadDirection) pt->direction; template->direction = (GstPadDirection) pt->direction;
template->static_caps.caps = NULL; template->static_caps.caps = NULL;
@ -543,7 +543,7 @@ gst_registry_chunks_load_pad_template (GstElementFactory * factory, gchar ** in,
fail: fail:
GST_INFO ("Reading pad template failed"); GST_INFO ("Reading pad template failed");
if (template) if (template)
g_slice_free (GstStaticPadTemplate, template); g_free (template);
return FALSE; return FALSE;
} }
@ -784,7 +784,7 @@ gst_registry_chunks_load_plugin_dep (GstPlugin * plugin, gchar ** in,
GST_LOG_OBJECT (plugin, "Unpacking GstRegistryChunkDep from %p", *in); GST_LOG_OBJECT (plugin, "Unpacking GstRegistryChunkDep from %p", *in);
unpack_element (*in, d, GstRegistryChunkDep, end, fail); unpack_element (*in, d, GstRegistryChunkDep, end, fail);
dep = g_slice_new (GstPluginDep); dep = g_new (GstPluginDep, 1);
dep->env_hash = d->env_hash; dep->env_hash = d->env_hash;
dep->stat_hash = d->stat_hash; dep->stat_hash = d->stat_hash;
@ -926,7 +926,7 @@ _priv_gst_registry_chunks_save_global_header (GList ** list,
GstRegistryChunkGlobalHeader *hdr; GstRegistryChunkGlobalHeader *hdr;
GstRegistryChunk *chk; GstRegistryChunk *chk;
hdr = g_slice_new (GstRegistryChunkGlobalHeader); hdr = g_new (GstRegistryChunkGlobalHeader, 1);
chk = gst_registry_chunks_make_data (hdr, chk = gst_registry_chunks_make_data (hdr,
sizeof (GstRegistryChunkGlobalHeader)); sizeof (GstRegistryChunkGlobalHeader));

View file

@ -29,7 +29,7 @@
/* /*
* we reference strings directly from the plugins and in this case set CONST to * we reference strings directly from the plugins and in this case set CONST to
* avoid freeing them. If g_free() should be used, the MALLOC flag is set, * avoid freeing them. If g_free() should be used, the MALLOC flag is set,
* otherwise g_slice_free1() will be used! * otherwise g_free() will also be used. (FIXME: don't need MALLOC flag any more)
*/ */
enum { enum {
GST_REGISTRY_CHUNK_FLAG_NONE = 0, GST_REGISTRY_CHUNK_FLAG_NONE = 0,

View file

@ -39,7 +39,7 @@ setup_pad_template (GstElementFactory * factory, GstStaticPadTemplate * tmpl)
{ {
GstStaticPadTemplate *template; GstStaticPadTemplate *template;
template = g_slice_dup (GstStaticPadTemplate, tmpl); template = g_memdup2 (tmpl, sizeof (GstStaticPadTemplate));
factory->staticpadtemplates = g_list_append (factory->staticpadtemplates, factory->staticpadtemplates = g_list_append (factory->staticpadtemplates,
template); template);
factory->numpadtemplates++; factory->numpadtemplates++;