mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
fix Dispose method by vishnu
Original commit message from CVS: fix Dispose method by vishnu
This commit is contained in:
parent
1f144436cb
commit
31f2a95bf4
2 changed files with 80 additions and 4 deletions
|
@ -198,15 +198,53 @@ gst_file_index_init (GstFileIndex *index)
|
|||
index->id_index = g_hash_table_new (g_int_hash, g_int_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
_file_index_id_free (GstFileIndexId *index_id, gboolean is_mmapped)
|
||||
{
|
||||
if (index_id->id_desc)
|
||||
g_free (index_id->id_desc);
|
||||
if (index_id->format)
|
||||
g_free (index_id->format);
|
||||
if (index_id->array) {
|
||||
if (is_mmapped)
|
||||
munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id));
|
||||
g_array_free (index_id->array, !is_mmapped);
|
||||
}
|
||||
g_free (index_id);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_id_index_free_helper (gpointer _key, GstFileIndexId *index_id,
|
||||
GstFileIndex *index)
|
||||
{
|
||||
_file_index_id_free (index_id, index->is_loaded);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_file_index_dispose (GObject *object)
|
||||
{
|
||||
GstFileIndex *index = GST_FILE_INDEX (object);
|
||||
|
||||
if (index->location)
|
||||
if (index->location) {
|
||||
g_free (index->location);
|
||||
index->location = NULL;
|
||||
}
|
||||
|
||||
// need to take care when destroying garrays with mmap'd segments
|
||||
{
|
||||
GSList *elem;
|
||||
for (elem = index->unresolved; elem; elem = g_slist_next (elem))
|
||||
_file_index_id_free (elem->data, index->is_loaded);
|
||||
g_slist_free (index->unresolved);
|
||||
index->unresolved = NULL;
|
||||
}
|
||||
|
||||
g_hash_table_foreach_steal (index->id_index,
|
||||
(GHRFunc) _id_index_free_helper, index);
|
||||
g_hash_table_destroy (index->id_index);
|
||||
index->id_index = NULL;
|
||||
|
||||
gst_index_entry_free (index->ret_entry); // hack
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
|
|
@ -198,15 +198,53 @@ gst_file_index_init (GstFileIndex *index)
|
|||
index->id_index = g_hash_table_new (g_int_hash, g_int_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
_file_index_id_free (GstFileIndexId *index_id, gboolean is_mmapped)
|
||||
{
|
||||
if (index_id->id_desc)
|
||||
g_free (index_id->id_desc);
|
||||
if (index_id->format)
|
||||
g_free (index_id->format);
|
||||
if (index_id->array) {
|
||||
if (is_mmapped)
|
||||
munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id));
|
||||
g_array_free (index_id->array, !is_mmapped);
|
||||
}
|
||||
g_free (index_id);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_id_index_free_helper (gpointer _key, GstFileIndexId *index_id,
|
||||
GstFileIndex *index)
|
||||
{
|
||||
_file_index_id_free (index_id, index->is_loaded);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_file_index_dispose (GObject *object)
|
||||
{
|
||||
GstFileIndex *index = GST_FILE_INDEX (object);
|
||||
|
||||
if (index->location)
|
||||
if (index->location) {
|
||||
g_free (index->location);
|
||||
index->location = NULL;
|
||||
}
|
||||
|
||||
// need to take care when destroying garrays with mmap'd segments
|
||||
{
|
||||
GSList *elem;
|
||||
for (elem = index->unresolved; elem; elem = g_slist_next (elem))
|
||||
_file_index_id_free (elem->data, index->is_loaded);
|
||||
g_slist_free (index->unresolved);
|
||||
index->unresolved = NULL;
|
||||
}
|
||||
|
||||
g_hash_table_foreach_steal (index->id_index,
|
||||
(GHRFunc) _id_index_free_helper, index);
|
||||
g_hash_table_destroy (index->id_index);
|
||||
index->id_index = NULL;
|
||||
|
||||
gst_index_entry_free (index->ret_entry); // hack
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue