This repository has been archived by the owner on Mar 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
/
issue8.cpp
70 lines (55 loc) · 1.67 KB
/
issue8.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#define USE_LOCKS 1
#define USE_DL_PREFIX 1
#define DEBUG 1
#define NO_NED_NAMESPACE
//#define INSECURE 1
//#define DEBUG 1
#define NEDMALLOCDEPRECATED
#define NEDMALLOC_DEBUG 1
//#define FULLSANITYCHECKS
//#define THREADCACHEMAX 0
//#define USE_MAGIC_HEADERS 1
//#define USE_ALLOCATOR 0
// #define MSPACES 1
// #define ONLY_MSPACES 1
#include "nedmalloc.c"
void MallocStabTest(){
printf("test\n");
void ** test=(void**)nedmalloc(1024*1024*16*sizeof(void**));
for(int i=0;i<(1024*1024*16);i++) test[i]=NULL;
for(int j=0;j<10000000;j++){
int testbyte=rand()%((1024*1024*16)-128);
for(int w=0;w<127;w++){
if(test[testbyte+w]){
nedfree(test[testbyte+w]);
test[testbyte+w]=NULL;
}
}
test[testbyte++]=nedmalloc(10);
test[testbyte++]=nedmalloc(40);
test[testbyte++]=nedmalloc(100);
test[testbyte+2]=nedmalloc(100);
test[testbyte+1]=nedmalloc(40);
test[testbyte]=nedmalloc(7);
testbyte+=3;
void * mallblocks[7];
size_t mallsz[7]={10,20,30,40,50,60,70};
nedindependent_comalloc(7, mallsz, mallblocks);
test[testbyte++]=mallblocks[0];
test[testbyte++]=mallblocks[6];
test[testbyte++]=mallblocks[2];
test[testbyte++]=mallblocks[5];
test[testbyte++]=mallblocks[4];
test[testbyte++]=mallblocks[3];
test[testbyte++]=mallblocks[1];
}
for(int i=0;i<(1024*1024*16);i++) if(test[i]) nedfree(test[i]);
nedfree(test);
printf("end\n");
}
int main(void)
{
MallocStabTest();
getchar();
return 0;
}