diff options
Diffstat (limited to 'apps/plugins/pdbox/dbestfit-3.3/dmytest.c')
-rw-r--r-- | apps/plugins/pdbox/dbestfit-3.3/dmytest.c | 276 |
1 files changed, 276 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/dbestfit-3.3/dmytest.c b/apps/plugins/pdbox/dbestfit-3.3/dmytest.c new file mode 100644 index 0000000000..46d4c73efd --- /dev/null +++ b/apps/plugins/pdbox/dbestfit-3.3/dmytest.c | |||
@@ -0,0 +1,276 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | |||
4 | #include "dmalloc.h" | ||
5 | |||
6 | #define MAX 500 | ||
7 | #define MAX2 1000 | ||
8 | #define MAXC 2 | ||
9 | |||
10 | #define TESTA | ||
11 | #define TESTB | ||
12 | #define TESTC | ||
13 | #define TESTD | ||
14 | |||
15 | int main(int argc, char **argv) | ||
16 | { | ||
17 | int i; | ||
18 | int memory = 0; | ||
19 | |||
20 | #ifdef BMALLOC | ||
21 | #define HEAP 10000 | ||
22 | void *heap = (malloc)(HEAP); | ||
23 | if(!heap) | ||
24 | return -1; | ||
25 | add_pool(heap, HEAP); | ||
26 | #endif | ||
27 | |||
28 | { | ||
29 | #define MAXK 100 | ||
30 | void *wow[MAXK]; | ||
31 | wow[0]=malloc(700); | ||
32 | realloc(wow[0], 680); | ||
33 | return 0; | ||
34 | |||
35 | for(i=0; i<MAXK; i++) | ||
36 | if(!(wow[i]=malloc(412))) { | ||
37 | printf("*** Couldn't allocated memory, exiting\n"); | ||
38 | return -2; | ||
39 | } | ||
40 | for(i=MAXK-1; i>=0; i-=2) | ||
41 | free(wow[i]); | ||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | |||
46 | #ifdef TESTD | ||
47 | { | ||
48 | #define MAXS 10 | ||
49 | #define MAXS1 0 | ||
50 | void *ptr[MAXS]; | ||
51 | |||
52 | for(i=MAXS1; i< MAXS; i++) { | ||
53 | printf("%d malloc(%d)\n", i, i*55); | ||
54 | ptr[i] = malloc (i*55); | ||
55 | } | ||
56 | for(i=MAXS1; i< MAXS; i++) { | ||
57 | void *tmp; | ||
58 | printf("%d realloc(%d)\n", i, i*155); | ||
59 | tmp=realloc(ptr[i], i*155); | ||
60 | if(tmp) | ||
61 | ptr[i] = tmp; | ||
62 | } | ||
63 | for(i=MAXS1; i< MAXS; i++) { | ||
64 | printf("%d free(%d)\n", i, i*155); | ||
65 | free(ptr[i]); | ||
66 | } | ||
67 | } | ||
68 | #endif | ||
69 | |||
70 | #ifdef TESTC | ||
71 | { | ||
72 | void *ptr[MAXC]; | ||
73 | printf("This is test C:\n"); | ||
74 | |||
75 | for(i=0; i< MAXC; i++) { | ||
76 | printf("%d malloc(100)\n", i+1); | ||
77 | ptr[i] = malloc(100); | ||
78 | printf(" ...returned %p\n", ptr[i]); | ||
79 | } | ||
80 | |||
81 | for(i=0; i< MAXC; i++) { | ||
82 | printf("%d free()\n", i+1); | ||
83 | free(ptr[i]); | ||
84 | } | ||
85 | |||
86 | printf("End of test C:\n"); | ||
87 | } | ||
88 | #endif | ||
89 | |||
90 | #ifdef TESTA | ||
91 | { | ||
92 | void *pointers[MAX]; | ||
93 | printf("This is test I:\n"); | ||
94 | |||
95 | for(i=0; i<MAX; i++) { | ||
96 | printf("%d attempts malloc(%d)\n", i, i*6); | ||
97 | pointers[i]=malloc(i*6); | ||
98 | if(!pointers[i]) { | ||
99 | printf("cant get more memory!"); | ||
100 | return(0); | ||
101 | } | ||
102 | memory += (i*6); | ||
103 | } | ||
104 | printf("\namount: %d\n", memory); | ||
105 | memory = 0; | ||
106 | for(i=0; i<MAX; i++) { | ||
107 | printf("%d attempts realloc(%d)\n", i, i*7); | ||
108 | pointers[i]=realloc(pointers[i], i*7); | ||
109 | memory += i*7; | ||
110 | } | ||
111 | printf("\namount: %d\n", memory); | ||
112 | for(i=0; i<MAX; i++) { | ||
113 | printf("%d attempts free(%d)\n", i, i*7); | ||
114 | free(pointers[i]); | ||
115 | } | ||
116 | printf("\nend of test 1\n"); | ||
117 | } | ||
118 | #endif | ||
119 | #ifdef TESTB | ||
120 | { | ||
121 | void *pointers2[MAX2]; | ||
122 | memory = 0; | ||
123 | printf("\nTest II\n"); | ||
124 | for(i=0; i< MAX2; i++) { | ||
125 | /* printf("%d attempts malloc(%d)\n", i, 7); */ | ||
126 | pointers2[i] = malloc(7); | ||
127 | memory += 7; | ||
128 | } | ||
129 | printf("\namount: %d\n", memory); | ||
130 | for(i=0; i< MAX2; i++) { | ||
131 | free(pointers2[i]); | ||
132 | } | ||
133 | printf("\nend of test II\n"); | ||
134 | |||
135 | } | ||
136 | #endif | ||
137 | return 0; | ||
138 | } | ||
139 | #include <stdio.h> | ||
140 | #include <stdlib.h> | ||
141 | |||
142 | #include "dmalloc.h" | ||
143 | |||
144 | #define MAX 500 | ||
145 | #define MAX2 1000 | ||
146 | #define MAXC 2 | ||
147 | |||
148 | #define TESTA | ||
149 | #define TESTB | ||
150 | #define TESTC | ||
151 | #define TESTD | ||
152 | |||
153 | int main(int argc, char **argv) | ||
154 | { | ||
155 | int i; | ||
156 | int memory = 0; | ||
157 | |||
158 | #ifdef BMALLOC | ||
159 | #define HEAP 10000 | ||
160 | void *heap = (malloc)(HEAP); | ||
161 | if(!heap) | ||
162 | return -1; | ||
163 | add_pool(heap, HEAP); | ||
164 | #endif | ||
165 | |||
166 | { | ||
167 | #define MAXK 100 | ||
168 | void *wow[MAXK]; | ||
169 | wow[0]=malloc(700); | ||
170 | realloc(wow[0], 680); | ||
171 | return 0; | ||
172 | |||
173 | for(i=0; i<MAXK; i++) | ||
174 | if(!(wow[i]=malloc(412))) { | ||
175 | printf("*** Couldn't allocated memory, exiting\n"); | ||
176 | return -2; | ||
177 | } | ||
178 | for(i=MAXK-1; i>=0; i-=2) | ||
179 | free(wow[i]); | ||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | |||
184 | #ifdef TESTD | ||
185 | { | ||
186 | #define MAXS 10 | ||
187 | #define MAXS1 0 | ||
188 | void *ptr[MAXS]; | ||
189 | |||
190 | for(i=MAXS1; i< MAXS; i++) { | ||
191 | printf("%d malloc(%d)\n", i, i*55); | ||
192 | ptr[i] = malloc (i*55); | ||
193 | } | ||
194 | for(i=MAXS1; i< MAXS; i++) { | ||
195 | void *tmp; | ||
196 | printf("%d realloc(%d)\n", i, i*155); | ||
197 | tmp=realloc(ptr[i], i*155); | ||
198 | if(tmp) | ||
199 | ptr[i] = tmp; | ||
200 | } | ||
201 | for(i=MAXS1; i< MAXS; i++) { | ||
202 | printf("%d free(%d)\n", i, i*155); | ||
203 | free(ptr[i]); | ||
204 | } | ||
205 | } | ||
206 | #endif | ||
207 | |||
208 | #ifdef TESTC | ||
209 | { | ||
210 | void *ptr[MAXC]; | ||
211 | printf("This is test C:\n"); | ||
212 | |||
213 | for(i=0; i< MAXC; i++) { | ||
214 | printf("%d malloc(100)\n", i+1); | ||
215 | ptr[i] = malloc(100); | ||
216 | printf(" ...returned %p\n", ptr[i]); | ||
217 | } | ||
218 | |||
219 | for(i=0; i< MAXC; i++) { | ||
220 | printf("%d free()\n", i+1); | ||
221 | free(ptr[i]); | ||
222 | } | ||
223 | |||
224 | printf("End of test C:\n"); | ||
225 | } | ||
226 | #endif | ||
227 | |||
228 | #ifdef TESTA | ||
229 | { | ||
230 | void *pointers[MAX]; | ||
231 | printf("This is test I:\n"); | ||
232 | |||
233 | for(i=0; i<MAX; i++) { | ||
234 | printf("%d attempts malloc(%d)\n", i, i*6); | ||
235 | pointers[i]=malloc(i*6); | ||
236 | if(!pointers[i]) { | ||
237 | printf("cant get more memory!"); | ||
238 | return(0); | ||
239 | } | ||
240 | memory += (i*6); | ||
241 | } | ||
242 | printf("\namount: %d\n", memory); | ||
243 | memory = 0; | ||
244 | for(i=0; i<MAX; i++) { | ||
245 | printf("%d attempts realloc(%d)\n", i, i*7); | ||
246 | pointers[i]=realloc(pointers[i], i*7); | ||
247 | memory += i*7; | ||
248 | } | ||
249 | printf("\namount: %d\n", memory); | ||
250 | for(i=0; i<MAX; i++) { | ||
251 | printf("%d attempts free(%d)\n", i, i*7); | ||
252 | free(pointers[i]); | ||
253 | } | ||
254 | printf("\nend of test 1\n"); | ||
255 | } | ||
256 | #endif | ||
257 | #ifdef TESTB | ||
258 | { | ||
259 | void *pointers2[MAX2]; | ||
260 | memory = 0; | ||
261 | printf("\nTest II\n"); | ||
262 | for(i=0; i< MAX2; i++) { | ||
263 | /* printf("%d attempts malloc(%d)\n", i, 7); */ | ||
264 | pointers2[i] = malloc(7); | ||
265 | memory += 7; | ||
266 | } | ||
267 | printf("\namount: %d\n", memory); | ||
268 | for(i=0; i< MAX2; i++) { | ||
269 | free(pointers2[i]); | ||
270 | } | ||
271 | printf("\nend of test II\n"); | ||
272 | |||
273 | } | ||
274 | #endif | ||
275 | return 0; | ||
276 | } | ||