Skip to content

Instantly share code, notes, and snippets.

@tetkuz
Created May 25, 2016 02:21
Show Gist options
  • Save tetkuz/04619fb71265925111b81823fde6f5e4 to your computer and use it in GitHub Desktop.
Save tetkuz/04619fb71265925111b81823fde6f5e4 to your computer and use it in GitHub Desktop.
gst_allocator_class.free() override
#include <stdio.h>
#include <gst/gst.h>
void my_free (GstAllocator * allocator, GstMemory * mem)
{
(void)allocator;
(void)mem;
g_print ("my_free(): Hello\n");
}
int main (int argc, char *argv[])
{
GstAllocator *allocator;
GstAllocatorClass *class;
GstMemory *mem;
gst_init (&argc, &argv);
allocator = gst_allocator_find (NULL);
class = GST_ALLOCATOR_GET_CLASS (allocator);
class->free = my_free;
mem = gst_allocator_alloc (allocator, 1, NULL);
gst_memory_unref(mem);
return 0;
}

alloc を default で行い、free を自前の関数で行なうのでメモリリークが発生するコード

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment