1 /********************************************************************
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5 * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
6 * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
9 * by the XIPHOPHORUS Company http://www.xiph.org/ *
11 ********************************************************************/
17 #include "vorbis/codec.h"
21 static pthread_mutex_t memlock=PTHREAD_MUTEX_INITIALIZER;
23 long *insertlist=NULL; /* We can't embed this in the pointer list;
24 a pointer can have any value... */
35 static void *_insert(void *ptr,char *file,long line){
36 ((head *)ptr)->file=file;
37 ((head *)ptr)->line=line;
38 ((head *)ptr)->ptr=pinsert;
40 pthread_mutex_lock(&memlock);
41 if(pinsert>=palloced){
44 pointers=(void **)realloc(pointers,sizeof(void **)*palloced);
45 insertlist=(long *)realloc(insertlist,sizeof(long *)*palloced);
47 pointers=(void **)malloc(sizeof(void **)*palloced);
48 insertlist=(long *)malloc(sizeof(long *)*palloced);
52 pointers[pinsert]=ptr;
57 pinsert=insertlist[pinsert];
59 pthread_mutex_unlock(&memlock);
60 return(ptr+HEAD_ALIGN);
63 static void _ripremove(void *ptr){
65 pthread_mutex_lock(&memlock);
66 insert=((head *)ptr)->ptr;
67 insertlist[insert]=pinsert;
69 pointers[insert]=NULL;
70 pthread_mutex_unlock(&memlock);
73 void _VDBG_dump(void){
75 pthread_mutex_lock(&memlock);
77 head *ptr=pointers[i];
79 fprintf(stderr,"unfreed bytes from %s:%ld\n",
83 pthread_mutex_unlock(&memlock);
86 extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line){
91 ptr=realloc(ptr,bytes);
96 return _insert(ptr,file,line);
99 extern void _VDBG_free(void *ptr,char *file,long line){