-/**
- * gst_allocator_new:
- * @info: a #GstMemoryInfo
- * @user_data: user data
- * @notify: a #GDestroyNotify for @user_data
- *
- * Create a new memory allocator with @info and @user_data.
- *
- * All functions in @info are mandatory exept the copy and is_span
- * functions, which will have a default implementation when left NULL.
- *
- * The @user_data will be passed to all calls of the alloc function. @notify
- * will be called with @user_data when the allocator is freed.
- *
- * Returns: a new #GstAllocator.
- */
-GstAllocator *
-gst_allocator_new (const GstMemoryInfo * info, gpointer user_data,
- GDestroyNotify notify)
-{
- GstAllocator *allocator;
-
-#define INSTALL_FALLBACK(_t) \
- if (allocator->info._t == NULL) allocator->info._t = _fallback_ ##_t;
-
- g_return_val_if_fail (info != NULL, NULL);
- g_return_val_if_fail (info->alloc != NULL, NULL);
- g_return_val_if_fail (info->mem_map != NULL, NULL);
- g_return_val_if_fail (info->mem_unmap != NULL, NULL);
- g_return_val_if_fail (info->mem_free != NULL, NULL);
- g_return_val_if_fail (info->mem_share != NULL, NULL);
-
- allocator = g_slice_new (GstAllocator);
- allocator->refcount = 1;
- allocator->info = *info;
- allocator->user_data = user_data;
- allocator->notify = notify;
- INSTALL_FALLBACK (mem_copy);
- INSTALL_FALLBACK (mem_is_span);
-#undef INSTALL_FALLBACK
-
- GST_CAT_DEBUG (GST_CAT_MEMORY, "new allocator %p", allocator);
-
-#ifndef GST_DISABLE_TRACE
- _gst_alloc_trace_new (_gst_allocator_trace, allocator);
-#endif
-
- return allocator;
-}
-
-/**
- * gst_allocator_get_memory_type:
- * @allocator: a #GstAllocator
- *
- * Get the memory type allocated by this allocator
- *
- * Returns: the memory type provided by @allocator
- */
-const gchar *
-gst_allocator_get_memory_type (GstAllocator * allocator)
-{
- g_return_val_if_fail (allocator != NULL, NULL);
-
- return allocator->info.mem_type;
-}
-
-/**
- * gst_allocator_ref:
- * @allocator: a #GstAllocator
- *
- * Increases the refcount of @allocator.
- *
- * Returns: @allocator with increased refcount
- */
-GstAllocator *
-gst_allocator_ref (GstAllocator * allocator)
-{
- g_return_val_if_fail (allocator != NULL, NULL);
-
- GST_CAT_TRACE (GST_CAT_MEMORY, "allocator %p, %d->%d", allocator,
- allocator->refcount, allocator->refcount + 1);
-
- g_atomic_int_inc (&allocator->refcount);
-
- return allocator;
-}
-
-/**
- * gst_allocator_unref:
- * @allocator: a #GstAllocator
- *
- * Decreases the refcount of @allocator. When the refcount reaches 0, the notify
- * function of @allocator will be called and the allocator will be freed.
- */
-void
-gst_allocator_unref (GstAllocator * allocator)
-{
- g_return_if_fail (allocator != NULL);
-
- GST_CAT_TRACE (GST_CAT_MEMORY, "allocator %p, %d->%d", allocator,
- allocator->refcount, allocator->refcount - 1);
-
- if (g_atomic_int_dec_and_test (&allocator->refcount)) {
- if (allocator->notify)
- allocator->notify (allocator->user_data);
-#ifndef GST_DISABLE_TRACE
- _gst_alloc_trace_free (_gst_allocator_trace, allocator);
-#endif
- g_slice_free1 (sizeof (GstAllocator), allocator);
- }
-}
-
-/**
- * gst_allocator_register:
- * @name: the name of the allocator
- * @allocator: (transfer full): #GstAllocator
- *
- * Registers the memory @allocator with @name. This function takes ownership of
- * @allocator.
- */
-void
-gst_allocator_register (const gchar * name, GstAllocator * allocator)
-{
- g_return_if_fail (name != NULL);
- g_return_if_fail (allocator != NULL);
-
- GST_CAT_DEBUG (GST_CAT_MEMORY, "registering allocator %p with name \"%s\"",
- allocator, name);
-
- g_rw_lock_writer_lock (&lock);
- g_hash_table_insert (allocators, (gpointer) name, (gpointer) allocator);
- g_rw_lock_writer_unlock (&lock);
-}
-
-/**
- * gst_allocator_find:
- * @name: the name of the allocator
- *
- * Find a previously registered allocator with @name. When @name is NULL, the
- * default allocator will be returned.
- *
- * Returns: (transfer full): a #GstAllocator or NULL when the allocator with @name was not
- * registered. Use gst_allocator_unref() to release the allocator after usage.
- */
-GstAllocator *
-gst_allocator_find (const gchar * name)
-{
- GstAllocator *allocator;
-
- g_rw_lock_reader_lock (&lock);
- if (name) {
- allocator = g_hash_table_lookup (allocators, (gconstpointer) name);
- } else {
- allocator = _default_allocator;
- }
- if (allocator)
- gst_allocator_ref (allocator);
- g_rw_lock_reader_unlock (&lock);
-
- return allocator;
-}
-
-/**
- * gst_allocator_set_default:
- * @allocator: (transfer full): a #GstAllocator
- *
- * Set the default allocator. This function takes ownership of @allocator.
- */
-void
-gst_allocator_set_default (GstAllocator * allocator)
-{
- GstAllocator *old;
- g_return_if_fail (allocator != NULL);
-
- g_rw_lock_writer_lock (&lock);
- old = _default_allocator;
- _default_allocator = allocator;
- g_rw_lock_writer_unlock (&lock);
-
- if (old)
- gst_allocator_unref (old);
-}
-
-/**
- * gst_allocation_params_init:
- * @params: a #GstAllocationParams
- *
- * Initialize @params to its default values
- */
-void
-gst_allocation_params_init (GstAllocationParams * params)
-{
- g_return_if_fail (params != NULL);
-
- memset (params, 0, sizeof (GstAllocationParams));
-}
-
-/**
- * gst_allocation_params_copy:
- * @params: (transfer none): a #GstAllocationParams
- *
- * Create a copy of @params.
- *
- * Free-function: gst_allocation_params_free
- *
- * Returns: (transfer full): a new ##GstAllocationParams, free with
- * gst_allocation_params_free().
- */
-GstAllocationParams *
-gst_allocation_params_copy (const GstAllocationParams * params)
-{
- GstAllocationParams *result = NULL;
-
- if (params) {
- result =
- (GstAllocationParams *) g_slice_copy (sizeof (GstAllocationParams),
- params);
- }
- return result;
-}
-
-/**
- * gst_allocation_params_free:
- * @params: (in) (transfer full): a #GstAllocationParams
- *
- * Free @params
- */