mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 10:25:33 +00:00
memory: fix copy function
Make the copy function map to ref because we can't safely copy the user_data.
This commit is contained in:
parent
a7793f1fd7
commit
db204ea24a
1 changed files with 13 additions and 29 deletions
|
@ -820,37 +820,10 @@ _gst_allocator_free (GstAllocator * allocator)
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (allocator), allocator);
|
g_slice_free1 (GST_MINI_OBJECT_SIZE (allocator), allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gst_allocator_init (GstAllocator * allocator,
|
|
||||||
const GstMemoryInfo * info, gsize size);
|
|
||||||
|
|
||||||
static GstAllocator *
|
static GstAllocator *
|
||||||
_gst_allocator_copy (GstAllocator * allocator)
|
_gst_allocator_copy (GstAllocator * allocator)
|
||||||
{
|
{
|
||||||
GstAllocator *copy;
|
return gst_allocator_ref (allocator);
|
||||||
|
|
||||||
copy = g_slice_new (GstAllocator);
|
|
||||||
|
|
||||||
gst_allocator_init (copy, &allocator->info, sizeof (GstAllocator));
|
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_allocator_init (GstAllocator * allocator, const GstMemoryInfo * info,
|
|
||||||
gsize size)
|
|
||||||
{
|
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (allocator),
|
|
||||||
gst_allocator_get_type (), size);
|
|
||||||
|
|
||||||
allocator->mini_object.copy = (GstMiniObjectCopyFunction) _gst_allocator_copy;
|
|
||||||
allocator->mini_object.free = (GstMiniObjectFreeFunction) _gst_allocator_free;
|
|
||||||
|
|
||||||
allocator->info = *info;
|
|
||||||
#define INSTALL_FALLBACK(_t) \
|
|
||||||
if (allocator->info._t == NULL) allocator->info._t = _fallback_ ##_t;
|
|
||||||
INSTALL_FALLBACK (mem_copy);
|
|
||||||
INSTALL_FALLBACK (mem_is_span);
|
|
||||||
#undef INSTALL_FALLBACK
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -884,11 +857,22 @@ gst_allocator_new (const GstMemoryInfo * info, gpointer user_data,
|
||||||
|
|
||||||
allocator = g_slice_new (GstAllocator);
|
allocator = g_slice_new (GstAllocator);
|
||||||
|
|
||||||
gst_allocator_init (allocator, info, sizeof (GstAllocator));
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (allocator),
|
||||||
|
gst_allocator_get_type (), sizeof (GstAllocator));
|
||||||
|
|
||||||
|
allocator->mini_object.copy = (GstMiniObjectCopyFunction) _gst_allocator_copy;
|
||||||
|
allocator->mini_object.free = (GstMiniObjectFreeFunction) _gst_allocator_free;
|
||||||
|
|
||||||
|
allocator->info = *info;
|
||||||
allocator->user_data = user_data;
|
allocator->user_data = user_data;
|
||||||
allocator->notify = notify;
|
allocator->notify = notify;
|
||||||
|
|
||||||
|
#define INSTALL_FALLBACK(_t) \
|
||||||
|
if (allocator->info._t == NULL) allocator->info._t = _fallback_ ##_t;
|
||||||
|
INSTALL_FALLBACK (mem_copy);
|
||||||
|
INSTALL_FALLBACK (mem_is_span);
|
||||||
|
#undef INSTALL_FALLBACK
|
||||||
|
|
||||||
GST_CAT_DEBUG (GST_CAT_MEMORY, "new allocator %p", allocator);
|
GST_CAT_DEBUG (GST_CAT_MEMORY, "new allocator %p", allocator);
|
||||||
|
|
||||||
return allocator;
|
return allocator;
|
||||||
|
|
Loading…
Reference in a new issue