1 /********************************************************************
3 * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5 * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
6 * PLEASE READ THESE TERMS DISTRIBUTING. *
8 * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
9 * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
10 * http://www.xiph.org/ *
12 ********************************************************************/
18 #include "vorbis/codec.h"
22 static pthread_mutex_t memlock=PTHREAD_MUTEX_INITIALIZER;
24 long *insertlist=NULL; /* We can't embed this in the pointer list;
25 a pointer can have any value... */
36 static void *_insert(void *ptr,char *file,long line){
37 ((head *)ptr)->file=file;
38 ((head *)ptr)->line=line;
39 ((head *)ptr)->ptr=pinsert;
41 pthread_mutex_lock(&memlock);
42 if(pinsert>=palloced){
45 pointers=(void **)realloc(pointers,sizeof(void **)*palloced);
46 insertlist=(long *)realloc(insertlist,sizeof(long *)*palloced);
48 pointers=(void **)malloc(sizeof(void **)*palloced);
49 insertlist=(long *)malloc(sizeof(long *)*palloced);
53 pointers[pinsert]=ptr;
58 pinsert=insertlist[pinsert];
60 pthread_mutex_unlock(&memlock);
61 return(ptr+HEAD_ALIGN);
64 static void _ripremove(void *ptr){
66 pthread_mutex_lock(&memlock);
67 insert=((head *)ptr)->ptr;
68 insertlist[insert]=pinsert;
70 pointers[insert]=NULL;
71 pthread_mutex_unlock(&memlock);
74 void _VDBG_dump(void){
76 pthread_mutex_lock(&memlock);
78 head *ptr=pointers[i];
80 fprintf(stderr,"unfreed bytes from %s:%ld\n",
84 pthread_mutex_unlock(&memlock);
87 extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line){
92 ptr=realloc(ptr,bytes);
97 return _insert(ptr,file,line);
100 extern void _VDBG_free(void *ptr,char *file,long line){