alloc を default で行い、free を自前の関数で行なうのでメモリリークが発生するコード
Created
May 25, 2016 02:21
-
-
Save tetkuz/04619fb71265925111b81823fde6f5e4 to your computer and use it in GitHub Desktop.
gst_allocator_class.free() override
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment