From 57ce0321c8971f964008920003a3e8b19649df85 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 3 Feb 2002 16:30:31 +0000 Subject: Added a tarkin encoder/decoder plugin. Original commit message from CVS: Added a tarkin encoder/decoder plugin. I moved the tarking CVS code in here temporarily until they have a library (hence this plugin is in ext) test with: ./gst-launch filesrc location=/opt/data/shihad.mpg ! mpegdemux video_00! { queue ! mpeg2dec ! colorspace ! tarkinenc bitrate=3000 ! disksink location=out.ogg } ./gst-launch filesrc location=out.ogg ! tarkindec ! colorspace ! xvideosink --- ext/tarkin/mem.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 ext/tarkin/mem.c (limited to 'ext/tarkin/mem.c') diff --git a/ext/tarkin/mem.c b/ext/tarkin/mem.c new file mode 100644 index 00000000..c2cf18c0 --- /dev/null +++ b/ext/tarkin/mem.c @@ -0,0 +1,143 @@ +/* + * Debugging implementation of MALLOC and friends + */ + + +#include "mem.h" + +#if defined(DBG_MEMLEAKS) + +typedef struct { + void *mem; + char *allocated_in_func; + char *allocated_in_file; + unsigned int allocated_in_line; +} MemDesc; + + +static int initialized = 0; +static int alloc_count = 0; +static MemDesc *alloc_list = NULL; + + +static +void dbg_memleaks_done (int exitcode, void *dummy) +{ + unsigned int i; + (void) dummy; + + if (exitcode == 0 && alloc_count != 0) { + fprintf (stderr, "\nmemory leak detected !!!\n"); + fprintf (stderr, "\nalloc_count == %i\n\n", alloc_count); + for (i=0; imem, d->allocated_in_func, d->allocated_in_file, + d->allocated_in_line); + } + free(alloc_list); + } + fprintf (stderr, "\n"); +} + + +static +void dbg_memleaks_init (void) +{ + on_exit (dbg_memleaks_done, NULL); + initialized = 1; +} + + +void* dbg_malloc (char* file, int line, char *func, size_t bytes) +{ + void *mem = (void*) malloc (bytes); + MemDesc *d; + + if (!initialized) + dbg_memleaks_init(); + + alloc_count++; + alloc_list = realloc (alloc_list, alloc_count * sizeof(MemDesc)); + + d = &alloc_list[alloc_count-1]; + d->mem = mem; + d->allocated_in_func = func; + d->allocated_in_file = file; + d->allocated_in_line = line; + + return mem; +} + + +void* dbg_calloc (char* file, int line, char *func, size_t count, size_t bytes) +{ + void *mem = (void*) calloc (count, bytes); + MemDesc *d; + + if (!initialized) + dbg_memleaks_init(); + + alloc_count++; + alloc_list = realloc (alloc_list, alloc_count * sizeof(MemDesc)); + + d = &alloc_list[alloc_count-1]; + d->mem = mem; + d->allocated_in_func = func; + d->allocated_in_file = file; + d->allocated_in_line = line; + + return mem; +} + + +void* dbg_realloc (char *file, int line, char *func, char *what, + void *mem, size_t bytes) +{ + unsigned int i; + + for (i=0; i