diff options
author | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-07-23 21:37:35 +0000 |
---|---|---|
committer | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-07-23 21:37:35 +0000 |
commit | 840cd1069292e3f29d18e57f2274ec1e979f858b (patch) | |
tree | 0ee1d43fa3863de53c99432dc32001e625703d1c /apps/plugins/pdbox/dbestfit-3.3/dmytest.c | |
parent | 0d9b7ec73e71188632a4fd584dfd745aeb7571b3 (diff) | |
download | rockbox-840cd1069292e3f29d18e57f2274ec1e979f858b.tar.gz rockbox-840cd1069292e3f29d18e57f2274ec1e979f858b.zip |
Another pdbox patch by Wincent Balin (FS #10416): switch to using TLSF as memory allocator. Probably the last patch I commit for him, next changes are for him :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22017 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/dbestfit-3.3/dmytest.c')
-rw-r--r-- | apps/plugins/pdbox/dbestfit-3.3/dmytest.c | 138 |
1 files changed, 0 insertions, 138 deletions
diff --git a/apps/plugins/pdbox/dbestfit-3.3/dmytest.c b/apps/plugins/pdbox/dbestfit-3.3/dmytest.c deleted file mode 100644 index ed12686b3d..0000000000 --- a/apps/plugins/pdbox/dbestfit-3.3/dmytest.c +++ /dev/null | |||
@@ -1,138 +0,0 @@ | |||
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 | } | ||