added demo of signal/uid handling feature
[tridge/junkcode.git] / memtest2.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 int main(int argc, char *argv[])
6 {
7         unsigned char *buf;
8         int size;
9         int i, count;
10
11         if (argc < 2) {
12                 printf("memtest <size>\n");
13                 exit(1);
14         }
15
16         size = atoi(argv[1]);
17
18         buf = (unsigned char *)malloc(size);
19         
20         count = 0;
21
22         while (1) {
23                 unsigned char v = count % 256;
24                 memset(buf, v, size);
25                 for (i=0;i<size;i++) {
26                         if (buf[i] != v) {
27                                 printf("\nbuf[%d]=0x%x v=0x%x\n", 
28                                        i, buf[i], v);
29                         }
30                 }
31                 count++;
32                 printf("%d\r", count);
33                 fflush(stdout);
34         }
35
36         return 0;
37 }