author | koda |
Fri, 21 Sep 2012 01:29:33 +0200 | |
changeset 7699 | 2455207a2c71 |
parent 7697 | 767d3c4153a1 |
permissions | -rw-r--r-- |
7697
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
1 |
/******************************************************************** |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
2 |
* * |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
3 |
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
4 |
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
5 |
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
6 |
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
7 |
* * |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
8 |
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
9 |
* by the XIPHOPHORUS Company http://www.xiph.org/ * |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
10 |
* * |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
11 |
********************************************************************/ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
12 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
13 |
#define HEAD_ALIGN 64 |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
14 |
#include <stdlib.h> |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
15 |
#include <string.h> |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
16 |
#include <stdio.h> |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
17 |
#define MISC_C |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
18 |
#include "misc.h" |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
19 |
#include <sys/time.h> |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
20 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
21 |
static void **pointers=NULL; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
22 |
static long *insertlist=NULL; /* We can't embed this in the pointer list; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
23 |
a pointer can have any value... */ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
24 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
25 |
static char **files=NULL; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
26 |
static long *file_bytes=NULL; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
27 |
static int filecount=0; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
28 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
29 |
static int ptop=0; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
30 |
static int palloced=0; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
31 |
static int pinsert=0; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
32 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
33 |
typedef struct { |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
34 |
char *file; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
35 |
long line; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
36 |
long ptr; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
37 |
long bytes; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
38 |
} head; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
39 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
40 |
long global_bytes=0; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
41 |
long start_time=-1; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
42 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
43 |
static void *_insert(void *ptr,long bytes,char *file,long line){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
44 |
((head *)ptr)->file=file; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
45 |
((head *)ptr)->line=line; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
46 |
((head *)ptr)->ptr=pinsert; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
47 |
((head *)ptr)->bytes=bytes-HEAD_ALIGN; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
48 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
49 |
if(pinsert>=palloced){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
50 |
palloced+=64; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
51 |
if(pointers){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
52 |
pointers=(void **)realloc(pointers,sizeof(void **)*palloced); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
53 |
insertlist=(long *)realloc(insertlist,sizeof(long *)*palloced); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
54 |
}else{ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
55 |
pointers=(void **)malloc(sizeof(void **)*palloced); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
56 |
insertlist=(long *)malloc(sizeof(long *)*palloced); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
57 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
58 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
59 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
60 |
pointers[pinsert]=ptr; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
61 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
62 |
if(pinsert==ptop) |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
63 |
pinsert=++ptop; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
64 |
else |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
65 |
pinsert=insertlist[pinsert]; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
66 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
67 |
#ifdef _VDBG_GRAPHFILE |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
68 |
{ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
69 |
FILE *out; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
70 |
struct timeval tv; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
71 |
static struct timezone tz; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
72 |
int i; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
73 |
char buffer[80]; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
74 |
gettimeofday(&tv,&tz); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
75 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
76 |
for(i=0;i<filecount;i++) |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
77 |
if(!strcmp(file,files[i]))break; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
78 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
79 |
if(i==filecount){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
80 |
filecount++; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
81 |
if(!files){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
82 |
files=malloc(filecount*sizeof(*files)); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
83 |
file_bytes=malloc(filecount*sizeof(*file_bytes)); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
84 |
}else{ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
85 |
files=realloc(files,filecount*sizeof(*files)); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
86 |
file_bytes=realloc(file_bytes,filecount*sizeof(*file_bytes)); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
87 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
88 |
files[i]=strdup(file); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
89 |
file_bytes[i]=0; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
90 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
91 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
92 |
file_bytes[i]+=bytes-HEAD_ALIGN; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
93 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
94 |
if(start_time==-1)start_time=(tv.tv_sec*1000)+(tv.tv_usec/1000); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
95 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
96 |
snprintf(buffer,80,"%s",file); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
97 |
if(strchr(buffer,'.'))strchr(buffer,'.')[0]=0; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
98 |
strcat(buffer,_VDBG_GRAPHFILE); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
99 |
out=fopen(buffer,"a"); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
100 |
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
101 |
file_bytes[i]-(bytes-HEAD_ALIGN)); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
102 |
fprintf(out,"%ld, %ld # FILE %s LINE %ld\n", |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
103 |
-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
104 |
file_bytes[i],file,line); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
105 |
fclose(out); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
106 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
107 |
out=fopen("total"_VDBG_GRAPHFILE,"a"); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
108 |
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
109 |
global_bytes); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
110 |
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
111 |
global_bytes+(bytes-HEAD_ALIGN)); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
112 |
fclose(out); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
113 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
114 |
#endif |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
115 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
116 |
global_bytes+=(bytes-HEAD_ALIGN); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
117 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
118 |
return(ptr+HEAD_ALIGN); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
119 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
120 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
121 |
static void _ripremove(void *ptr){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
122 |
int insert; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
123 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
124 |
#ifdef _VDBG_GRAPHFILE |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
125 |
{ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
126 |
FILE *out=fopen("total"_VDBG_GRAPHFILE,"a"); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
127 |
struct timeval tv; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
128 |
static struct timezone tz; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
129 |
char buffer[80]; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
130 |
char *file =((head *)ptr)->file; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
131 |
long bytes =((head *)ptr)->bytes; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
132 |
int i; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
133 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
134 |
gettimeofday(&tv,&tz); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
135 |
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
136 |
global_bytes); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
137 |
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
138 |
global_bytes-((head *)ptr)->bytes); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
139 |
fclose(out); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
140 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
141 |
for(i=0;i<filecount;i++) |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
142 |
if(!strcmp(file,files[i]))break; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
143 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
144 |
snprintf(buffer,80,"%s",file); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
145 |
if(strchr(buffer,'.'))strchr(buffer,'.')[0]=0; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
146 |
strcat(buffer,_VDBG_GRAPHFILE); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
147 |
out=fopen(buffer,"a"); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
148 |
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
149 |
file_bytes[i]); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
150 |
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
151 |
file_bytes[i]-bytes); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
152 |
fclose(out); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
153 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
154 |
file_bytes[i]-=bytes; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
155 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
156 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
157 |
#endif |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
158 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
159 |
global_bytes-=((head *)ptr)->bytes; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
160 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
161 |
insert=((head *)ptr)->ptr; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
162 |
insertlist[insert]=pinsert; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
163 |
pinsert=insert; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
164 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
165 |
if(pointers[insert]==NULL){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
166 |
fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing previously freed memory\n"); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
167 |
fprintf(stderr,"\t%s %ld\n",((head *)ptr)->file,((head *)ptr)->line); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
168 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
169 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
170 |
if(global_bytes<0){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
171 |
fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing unmalloced memory\n"); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
172 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
173 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
174 |
pointers[insert]=NULL; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
175 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
176 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
177 |
void _VDBG_dump(void){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
178 |
int i; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
179 |
for(i=0;i<ptop;i++){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
180 |
head *ptr=pointers[i]; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
181 |
if(ptr) |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
182 |
fprintf(stderr,"unfreed bytes from %s:%ld\n", |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
183 |
ptr->file,ptr->line); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
184 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
185 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
186 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
187 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
188 |
extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
189 |
if(bytes<0) abort(); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
190 |
bytes+=HEAD_ALIGN; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
191 |
if(ptr){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
192 |
ptr-=HEAD_ALIGN; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
193 |
_ripremove(ptr); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
194 |
ptr=realloc(ptr,bytes); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
195 |
}else{ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
196 |
ptr=malloc(bytes); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
197 |
memset(ptr,0,bytes); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
198 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
199 |
return _insert(ptr,bytes,file,line); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
200 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
201 |
|
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
202 |
extern void _VDBG_free(void *ptr,char *file,long line){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
203 |
if(ptr){ |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
204 |
ptr-=HEAD_ALIGN; |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
205 |
_ripremove(ptr); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
206 |
free(ptr); |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
207 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
208 |
} |
767d3c4153a1
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff
changeset
|
209 |