+ 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);