GST_STATE_UNLOCK (bin);
GST_DEBUG_OBJECT (bin, "state continue done");
gst_object_unref (bin);
- g_free (data);
+ g_slice_free (BinContinueData, data);
return;
interrupted:
GST_STATE_UNLOCK (bin);
GST_DEBUG_OBJECT (bin, "state continue aborted due to intervening change");
gst_object_unref (bin);
- g_free (data);
+ g_slice_free (BinContinueData, data);
return;
}
}
"continue state change, pending %s",
gst_element_state_get_name (pending));
- cont = g_new0 (BinContinueData, 1);
+ cont = g_slice_new (BinContinueData);
/* ref to the bin */
cont->bin = gst_object_ref (bin);
poll_data->source_running = FALSE;
if (!poll_data->timeout_id) {
g_main_loop_unref (poll_data->loop);
- g_free (poll_data);
+ g_slice_free (GstBusPollData, poll_data);
}
}
poll_data->timeout_id = 0;
if (!poll_data->source_running) {
g_main_loop_unref (poll_data->loop);
- g_free (poll_data);
+ g_slice_free (GstBusPollData, poll_data);
}
}
GstMessage *ret;
gulong id;
- poll_data = g_new0 (GstBusPollData, 1);
+ poll_data = g_slice_new (GstBusPollData);
poll_data->source_running = TRUE;
poll_data->loop = g_main_loop_new (NULL, FALSE);
poll_data->events = events;
GST_STATE_PENDING (element) = GST_STATE_VOID_PENDING;
GST_STATE_RETURN (element) = GST_STATE_CHANGE_SUCCESS;
- element->state_lock = g_new0 (GStaticRecMutex, 1);
+ /* FIXME 0.11: Store this directly in the instance struct */
+ element->state_lock = g_slice_new (GStaticRecMutex);
g_static_rec_mutex_init (element->state_lock);
element->state_cond = g_cond_new ();
}
element->state_cond = NULL;
GST_STATE_UNLOCK (element);
g_static_rec_mutex_free (element->state_lock);
- g_free (element->state_lock);
+ g_slice_free (GStaticRecMutex, element->state_lock);
element->state_lock = NULL;
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "finalize parent");
g_ptr_array_free (caps->structs, TRUE);
caps->refcount = 0;
}
- g_free (templ);
+ g_slice_free (GstStaticPadTemplate, templ);
}
g_list_free (factory->staticpadtemplates);
factory->staticpadtemplates = NULL;
GstPadTemplate *templ = item->data;
GstStaticPadTemplate *newt;
- newt = g_new0 (GstStaticPadTemplate, 1);
+ newt = g_slice_new (GstStaticPadTemplate);
newt->name_template = g_intern_string (templ->name_template);
newt->direction = templ->direction;
newt->presence = templ->presence;
+ newt->static_caps.caps.refcount = 0;
newt->static_caps.string = gst_caps_to_string (templ->caps);
factory->staticpadtemplates =
g_list_append (factory->staticpadtemplates, newt);
return query;
g_static_mutex_lock (&mutex);
- format = g_new0 (GstFormatDefinition, 1);
+ format = g_slice_new (GstFormatDefinition);
format->value = _n_values;
format->nick = g_strdup (nick);
format->description = g_strdup (description);
GValue * value, GParamSpec * pspec);
static GstIndexGroup *gst_index_group_new (guint groupnum);
+static void gst_index_group_free (GstIndexGroup * group);
static gboolean gst_index_path_resolver (GstIndex * index, GstObject * writer,
gchar ** writer_string, gpointer data);
GstIndex *index = GST_INDEX (object);
if (index->groups) {
- g_list_foreach (index->groups, (GFunc) g_free, NULL);
+ g_list_foreach (index->groups, (GFunc) gst_index_group_free, NULL);
g_list_free (index->groups);
index->groups = NULL;
}
static GstIndexGroup *
gst_index_group_new (guint groupnum)
{
- GstIndexGroup *indexgroup = g_new (GstIndexGroup, 1);
+ GstIndexGroup *indexgroup = g_slice_new (GstIndexGroup);
indexgroup->groupnum = groupnum;
indexgroup->entries = NULL;
return indexgroup;
}
+static void
+gst_index_group_free (GstIndexGroup * group)
+{
+ g_slice_free (GstIndexGroup, group);
+}
+
/**
* gst_index_new:
*
GstIndexEntry *
gst_index_entry_copy (GstIndexEntry * entry)
{
- return g_memdup (entry, sizeof (*entry));
+ GstIndexEntry *new_entry = g_slice_new (GstIndexEntry);
+
+ memcpy (new_entry, entry, sizeof (GstIndexEntry));
+ return new_entry;
}
/**
break;
}
- g_free (entry);
+ g_slice_free (GstIndexEntry, entry);
}
/**
if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
return NULL;
- entry = g_new0 (GstIndexEntry, 1);
+ entry = g_slice_new (GstIndexEntry);
entry->type = GST_INDEX_ENTRY_FORMAT;
entry->id = id;
entry->data.format.format = format;
if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
return NULL;
- entry = g_new0 (GstIndexEntry, 1);
+ entry = g_slice_new (GstIndexEntry);
entry->type = GST_INDEX_ENTRY_ID;
entry->id = id;
entry->data.id.description = description;
if (!entry) {
/* index is probably not writable, make an entry anyway
* to keep it in our cache */
- entry = g_new0 (GstIndexEntry, 1);
+ entry = g_slice_new (GstIndexEntry);
entry->type = GST_INDEX_ENTRY_ID;
entry->id = *id;
entry->data.id.description = writer_string;
if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
return NULL;
- entry = g_malloc (sizeof (GstIndexEntry));
+ entry = g_slice_new (GstIndexEntry);
entry->type = GST_INDEX_ENTRY_ASSOCIATION;
entry->id = id;
g_return_if_fail (func != NULL);
- entry = g_new (LogFuncEntry, 1);
+ entry = g_slice_new (LogFuncEntry);
entry->func = func;
entry->user_data = data;
/* FIXME: we leak the old list here - other threads might access it right now
new = g_slist_copy (new);
continue;
}
- g_free (found->data);
+ g_slice_free (LogFuncEntry, found->data);
new = g_slist_delete_link (new, found);
removals++;
}
g_return_if_fail (name != NULL);
pat = g_pattern_spec_new (name);
- entry = g_new (LevelNameEntry, 1);
+ entry = g_slice_new (LevelNameEntry);
entry->pat = pat;
entry->level = level;
g_static_mutex_lock (&__level_name_mutex);
if (g_pattern_spec_equal (entry->pat, pat)) {
__level_name = g_slist_remove_link (__level_name, walk);
g_pattern_spec_free (entry->pat);
- g_free (entry);
+ g_slice_free (LevelNameEntry, entry);
g_slist_free_1 (walk);
walk = __level_name;
}
g_return_val_if_fail (name != NULL, NULL);
- cat = g_new (GstDebugCategory, 1);
+ cat = g_slice_new (GstDebugCategory);
cat->name = g_strdup (name);
cat->color = color;
if (description != NULL) {
g_free ((gpointer) category->name);
g_free ((gpointer) category->description);
- g_free (category);
+ g_slice_free (GstDebugCategory, category);
}
/**
G_TYPE_PARAM);
klass->path_string_separator = "/";
- klass->lock = g_new0 (GStaticRecMutex, 1);
+ /* FIXME 0.11: Store this directly in the class struct */
+ klass->lock = g_slice_new (GStaticRecMutex);
g_static_rec_mutex_init (klass->lock);
klass->signal_object = g_object_newv (gst_signal_object_get_type (), 0, NULL);
pad->preroll_lock = g_mutex_new ();
pad->preroll_cond = g_cond_new ();
- pad->stream_rec_lock = g_new (GStaticRecMutex, 1);
+ /* FIXME 0.11: Store this directly in the instance struct */
+ pad->stream_rec_lock = g_slice_new (GStaticRecMutex);
g_static_rec_mutex_init (pad->stream_rec_lock);
pad->block_cond = g_cond_new ();
if (pad->stream_rec_lock) {
g_static_rec_mutex_free (pad->stream_rec_lock);
- g_free (pad->stream_rec_lock);
+ g_slice_free (GStaticRecMutex, pad->stream_rec_lock);
pad->stream_rec_lock = NULL;
}
if (pad->preroll_lock) {
int_link_iter_data_free (IntLinkIterData * data)
{
g_list_free (data->list);
- g_free (data);
+ g_slice_free (IntLinkIterData, data);
}
#endif
* INTLINKFUNC() returned a different list but then this would only work if
* two concurrent iterators were used and the last iterator would still be
* thread-unsafe. Just don't use this method anymore. */
- data = g_new0 (IntLinkIterData, 1);
+ data = g_slice_new (IntLinkIterData);
data->list = GST_PAD_INTLINKFUNC (pad) (pad);
data->cookie = 0;
g_strfreev (dep->env_vars);
g_strfreev (dep->paths);
g_strfreev (dep->names);
- g_free (dep);
+ g_slice_free (GstPluginDep, dep);
}
static gboolean
}
}
- dep = g_new0 (GstPluginDep, 1);
+ dep = g_slice_new (GstPluginDep);
dep->env_vars = g_strdupv ((gchar **) env_vars);
dep->paths = g_strdupv ((gchar **) paths);
static GstPluginLoader *
plugin_loader_new (GstRegistry * registry)
{
- GstPluginLoader *l = g_new0 (GstPluginLoader, 1);
+ GstPluginLoader *l = g_slice_new0 (GstPluginLoader);
if (registry)
l->registry = gst_object_ref (registry);
while (cur) {
PendingPluginEntry *entry = (PendingPluginEntry *) (cur->data);
g_free (entry->filename);
- g_free (entry);
+ g_slice_free (PendingPluginEntry, entry);
cur = g_list_delete_link (cur, cur);
}
- g_free (loader);
+ g_slice_free (GstPluginLoader, loader);
return got_plugin_details;
}
GST_LOG_OBJECT (loader->registry,
"Sending file %s to child. tag %u", filename, loader->next_tag);
- entry = g_new (PendingPluginEntry, 1);
+ entry = g_slice_new (PendingPluginEntry);
entry->tag = loader->next_tag++;
entry->filename = g_strdup (filename);
entry->file_size = file_size;
GstRegistryChunk *cur = walk->data;
put_chunk (l, cur, &offset);
- if (!(cur->flags & GST_REGISTRY_CHUNK_FLAG_CONST))
- g_free (cur->data);
- g_free (cur);
+ _priv_gst_registry_chunk_free (cur);
}
g_list_free (chunks);
for (walk = chunks; walk; walk = g_list_next (walk)) {
GstRegistryChunk *cur = walk->data;
- if (!(cur->flags & GST_REGISTRY_CHUNK_FLAG_CONST))
- g_free (cur->data);
- g_free (cur);
+ _priv_gst_registry_chunk_free (cur);
}
g_list_free (chunks);
} else {
cur = g_list_delete_link (cur, cur);
g_free (e->filename);
- g_free (e);
+ g_slice_free (PendingPluginEntry, e);
}
}
if (entry != NULL) {
g_free (entry->filename);
- g_free (entry);
+ g_slice_free (PendingPluginEntry, entry);
}
/* Remove the plugin entry we just loaded */
if (lookup != GST_QUERY_NONE)
return lookup;
- query = g_new0 (GstQueryTypeDefinition, 1);
+ query = g_slice_new (GstQueryTypeDefinition);
query->value = _n_values;
query->nick = g_strdup (nick);
query->description = g_strdup (description);
static BinaryRegistryCache *
gst_registry_binary_cache_init (GstRegistry * registry, const char *location)
{
- BinaryRegistryCache *cache = g_new0 (BinaryRegistryCache, 1);
+ BinaryRegistryCache *cache = g_slice_new0 (BinaryRegistryCache);
cache->location = location;
return cache;
}
}
g_free (cache->mem);
- g_free (cache);
+ g_slice_free (BinaryRegistryCache, cache);
return ret;
}
static BinaryRegistryCache *
gst_registry_binary_cache_init (GstRegistry * registry, const char *location)
{
- BinaryRegistryCache *cache = g_new0 (BinaryRegistryCache, 1);
+ BinaryRegistryCache *cache = g_slice_new0 (BinaryRegistryCache);
cache->location = location;
cache->tmp_location = g_strconcat (location, ".tmpXXXXXX", NULL);
if (cache->cache_fd == -1) {
GST_DEBUG ("g_mkstemp() failed: %s", g_strerror (errno));
g_free (cache->tmp_location);
- g_free (cache);
+ g_slice_free (BinaryRegistryCache, cache);
return NULL;
}
}
}
g_free (cache->tmp_location);
- g_free (cache);
+ g_slice_free (BinaryRegistryCache, cache);
GST_INFO ("Wrote binary registry cache");
return TRUE;
{
g_unlink (cache->tmp_location);
g_free (cache->tmp_location);
- g_free (cache);
+ g_slice_free (BinaryRegistryCache, cache);
return FALSE;
}
fsync_failed:
gboolean res;
res = gst_registry_binary_write_chunk (cache, cur, &file_position);
- if (!(cur->flags & GST_REGISTRY_CHUNK_FLAG_CONST))
- g_free (cur->data);
- g_free (cur);
+
+ _priv_gst_registry_chunk_free (cur);
walk->data = NULL;
if (!res)
goto fail_free_list;
for (walk = to_write; walk; walk = g_list_next (walk)) {
GstRegistryChunk *cur = walk->data;
- if (cur) {
- if (!(cur->flags & GST_REGISTRY_CHUNK_FLAG_CONST))
- g_free (cur->data);
- g_free (cur);
- }
+ if (cur)
+ _priv_gst_registry_chunk_free (cur);
}
g_list_free (to_write);
#define alignment(_address) (gsize)_address%ALIGNMENT
#define align(_ptr) _ptr += (( alignment(_ptr) == 0) ? 0 : ALIGNMENT-alignment(_ptr))
+void
+_priv_gst_registry_chunk_free (GstRegistryChunk * chunk)
+{
+ if (!(chunk->flags & GST_REGISTRY_CHUNK_FLAG_CONST)) {
+ if ((chunk->flags & GST_REGISTRY_CHUNK_FLAG_MALLOC))
+ g_free (chunk->data);
+ else
+ g_slice_free1 (chunk->size, chunk->data);
+ }
+ g_slice_free (GstRegistryChunk, chunk);
+}
+
/*
* gst_registry_chunks_save_const_string:
*
str = "";
}
- chunk = g_malloc (sizeof (GstRegistryChunk));
+ chunk = g_slice_new (GstRegistryChunk);
chunk->data = (gpointer) str;
chunk->size = strlen ((gchar *) chunk->data) + 1;
chunk->flags = GST_REGISTRY_CHUNK_FLAG_CONST;
{
GstRegistryChunk *chunk;
- chunk = g_malloc (sizeof (GstRegistryChunk));
+ chunk = g_slice_new (GstRegistryChunk);
chunk->data = str;
chunk->size = strlen ((gchar *) chunk->data) + 1;
- chunk->flags = GST_REGISTRY_CHUNK_FLAG_NONE;
+ chunk->flags = GST_REGISTRY_CHUNK_FLAG_MALLOC;
chunk->align = FALSE;
*list = g_list_prepend (*list, chunk);
return TRUE;
{
GstRegistryChunk *chunk;
- chunk = g_malloc (sizeof (GstRegistryChunk));
+ chunk = g_slice_new (GstRegistryChunk);
chunk->data = data;
chunk->size = size;
chunk->flags = GST_REGISTRY_CHUNK_FLAG_NONE;
GstRegistryChunkPadTemplate *pt;
GstRegistryChunk *chk;
- pt = g_malloc0 (sizeof (GstRegistryChunkPadTemplate));
+ pt = g_slice_new (GstRegistryChunkPadTemplate);
chk =
gst_registry_chunks_make_data (pt, sizeof (GstRegistryChunkPadTemplate));
GstRegistryChunkElementFactory *ef;
GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
- ef = g_malloc0 (sizeof (GstRegistryChunkElementFactory));
+ ef = g_slice_new (GstRegistryChunkElementFactory);
chk =
gst_registry_chunks_make_data (ef,
sizeof (GstRegistryChunkElementFactory));
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
gchar *str;
- tff = g_malloc0 (sizeof (GstRegistryChunkTypeFindFactory));
+ tff = g_slice_new (GstRegistryChunkTypeFindFactory);
chk =
gst_registry_chunks_make_data (tff,
sizeof (GstRegistryChunkTypeFindFactory));
} else if (GST_IS_INDEX_FACTORY (feature)) {
GstIndexFactory *factory = GST_INDEX_FACTORY (feature);
- pf = g_malloc0 (sizeof (GstRegistryChunkPluginFeature));
+ pf = g_slice_new (GstRegistryChunkPluginFeature);
chk =
gst_registry_chunks_make_data (pf,
sizeof (GstRegistryChunkPluginFeature));
- pf->rank = feature->rank;
/* pack element factory strings */
gst_registry_chunks_save_const_string (list, factory->longdesc);
GstRegistryChunk *chk;
gchar **s;
- ed = g_malloc0 (sizeof (GstRegistryChunkDep));
+ ed = g_slice_new (GstRegistryChunkDep);
chk = gst_registry_chunks_make_data (ed, sizeof (GstRegistryChunkDep));
ed->flags = dep->flags;
GList *plugin_features = NULL;
GList *walk;
- pe = g_malloc0 (sizeof (GstRegistryChunkPluginElement));
+ pe = g_slice_new (GstRegistryChunkPluginElement);
chk =
gst_registry_chunks_make_data (pe,
sizeof (GstRegistryChunkPluginElement));
*in);
unpack_element (*in, pt, GstRegistryChunkPadTemplate, end, fail);
- template = g_new0 (GstStaticPadTemplate, 1);
+ template = g_slice_new (GstStaticPadTemplate);
template->presence = pt->presence;
template->direction = pt->direction;
+ template->static_caps.caps.refcount = 0;
/* unpack pad template strings */
unpack_const_string (*in, template->name_template, end, fail);
return TRUE;
fail:
GST_INFO ("Reading pad template failed");
- g_free (template);
+ if (template)
+ g_slice_free (GstStaticPadTemplate, template);
return FALSE;
}
GST_LOG_OBJECT (plugin, "Unpacking GstRegistryChunkDep from %p", *in);
unpack_element (*in, d, GstRegistryChunkDep, end, fail);
- dep = g_malloc0 (sizeof (GstPluginDep));
+ dep = g_slice_new (GstPluginDep);
dep->env_hash = d->env_hash;
dep->stat_hash = d->stat_hash;
/*
* we reference strings directly from the plugins and in this case set CONST to
- * avoid freeing them
+ * avoid freeing them. If g_free() should be used, the MALLOC flag is set,
+ * otherwise g_slice_free1() will be used!
*/
enum {
GST_REGISTRY_CHUNK_FLAG_NONE = 0,
- GST_REGISTRY_CHUNK_FLAG_CONST = 1
+ GST_REGISTRY_CHUNK_FLAG_CONST = 1,
+ GST_REGISTRY_CHUNK_FLAG_MALLOC = 2,
};
/*
_priv_gst_registry_chunks_load_plugin (GstRegistry * registry, gchar ** in,
gchar *end, GstPlugin **out_plugin);
+void
+_priv_gst_registry_chunk_free (GstRegistryChunk *chunk);
+
G_END_DECLS
#endif /* __GST_REGISTRYCHUNKS_H__ */
return;
}
- info = g_new (GstTagInfo, 1);
+ info = g_slice_new (GstTagInfo);
info->flag = flag;
info->type = type;
info->nick = g_strdup (nick);
if (data->list)
gst_tag_list_free (data->list);
- g_free (data);
+ g_slice_free (GstTagData, data);
}
static GstTagData *
data = g_object_get_qdata (G_OBJECT (setter), gst_tag_key);
if (!data) {
- data = g_new (GstTagData, 1);
+ data = g_slice_new (GstTagData);
data->list = NULL;
data->mode = GST_TAG_MERGE_KEEP;
g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data,
GstTrace *
gst_trace_new (const gchar * filename, gint size)
{
- GstTrace *trace = g_malloc (sizeof (GstTrace));
+ GstTrace *trace = g_slice_new (GstTrace);
g_return_val_if_fail (trace != NULL, NULL);
trace->filename = g_strdup (filename);
gst_trace_flush (trace);
close (trace->fd);
g_free (trace->buf);
- g_free (trace);
+ g_slice_free (GstTrace, trace);
}
/**
g_return_val_if_fail (name, NULL);
- trace = g_new0 (GstAllocTrace, 1);
+ trace = g_slice_new (GstAllocTrace);
trace->name = g_strdup (name);
trace->live = 0;
trace->mem_live = NULL;