projects
/
tedtools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
78483e9
)
more coorect comparing
author
teodor
<teodor>
Thu, 10 Feb 2005 16:46:25 +0000
(16:46 +0000)
committer
teodor
<teodor>
Thu, 10 Feb 2005 16:46:25 +0000
(16:46 +0000)
memtest.c
patch
|
blob
|
history
diff --git
a/memtest.c
b/memtest.c
index
2cb2040
..
223b49b
100644
(file)
--- a/
memtest.c
+++ b/
memtest.c
@@
-41,7
+41,7
@@
static void
usage() {
puts(
"Usage:\n"
usage() {
puts(
"Usage:\n"
- "memtest [-c COUNT [-
m
]]\n"
+ "memtest [-c COUNT [-
t
]]\n"
);
exit(1);
}
);
exit(1);
}
@@
-60,12
+60,12
@@
main(int argn, char *argv[]) {
opentlog(TL_OPEN_STDERR,TL_DEBUG, NULL);
opterr=0;
opentlog(TL_OPEN_STDERR,TL_DEBUG, NULL);
opterr=0;
- while((i=getopt(argn,argv,"c:h
m
")) != EOF) {
+ while((i=getopt(argn,argv,"c:h
t
")) != EOF) {
switch(i) {
case 'c':
count=atoi(optarg);
break;
switch(i) {
case 'c':
count=atoi(optarg);
break;
- case '
m
':
+ case '
t
':
iscntx=1;
break;
case 'h':
iscntx=1;
break;
case 'h':
@@
-156,11
+156,15
@@
main(int argn, char *argv[]) {
*ptr = (i+3)%256;
}
*ptr = (i+3)%256;
}
+ freeMemoryContext(base);
printf("MC elapsed: %f sec\n", elapsedtime(&begin));
printf("MC elapsed: %f sec\n", elapsedtime(&begin));
- freeMemoryContext(base);
} else {
} else {
+ char **all, **allptr;
gettimeofday(&begin, NULL);
gettimeofday(&begin, NULL);
+ allptr=all=malloc(sizeof(char*)*count*2);
+ if ( !all )
+ tlog(TL_CRIT|TL_EXIT,"No memory");
for(i=0;i<count;i++) {
ptr = malloc( 1+random()%SZ );
ptr1 = malloc( 1+random()%SZ );
for(i=0;i<count;i++) {
ptr = malloc( 1+random()%SZ );
ptr1 = malloc( 1+random()%SZ );
@@
-175,15
+179,22
@@
main(int argn, char *argv[]) {
tlog(TL_CRIT|TL_EXIT,"No memory");
*ptr = (i+1)%256;
tlog(TL_CRIT|TL_EXIT,"No memory");
*ptr = (i+1)%256;
- ptr1=malloc( 1+random()%SZ );
+ *allptr = ptr1=malloc( 1+random()%SZ );
+ allptr++;
*ptr1 = (i+2)%256;
*ptr1 = (i+2)%256;
- ptr = realloc(ptr, 1+random()%SZ );
+ *allptr = ptr = realloc(ptr, 1+random()%SZ );
+ allptr++;
if ( !ptr )
tlog(TL_CRIT|TL_EXIT,"No memory");
*ptr = (i+3)%256;
if ( !ptr )
tlog(TL_CRIT|TL_EXIT,"No memory");
*ptr = (i+3)%256;
-
}
}
+ allptr=all;
+ while( allptr-all < count ) {
+ free(*allptr);
+ allptr++;
+ }
+ free(all);
printf("Malloc elapsed: %f sec\n", elapsedtime(&begin));
}
printf("Malloc elapsed: %f sec\n", elapsedtime(&begin));
}