Changeset 1747 for zzuf/trunk/test/zzcat.c
- Timestamp:
- Feb 19, 2007, 11:25:54 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/test/zzcat.c
r1746 r1747 113 113 for(i = 0; i < 128; i++) 114 114 { 115 int moff = myrand() % len; 116 int mlen = myrand() % (len - moff); 117 char *map = mmap(NULL, mlen, PROT_READ, MAP_PRIVATE, fd, moff); 115 char *map; 116 int moff, mlen, pgsz = len + 1; 117 #ifdef HAVE_GETPAGESIZE 118 pgsz = getpagesize(); 119 #endif 120 moff = len < pgsz ? 0 : (myrand() % (len / pgsz)) * pgsz; 121 mlen = 1 + (myrand() % (len - moff)); 122 map = mmap(NULL, mlen, PROT_READ, MAP_PRIVATE, fd, moff); 123 if(map == MAP_FAILED) 124 return EXIT_FAILURE; 118 125 for(j = 0; j < 128; j++) 119 126 { 120 127 int x = myrand() % mlen; 121 data[moff + x] = data[x];128 data[moff + x] = map[x]; 122 129 } 123 130 munmap(map, mlen); … … 125 132 #endif 126 133 close(fd); 134 break; 135 default: 136 return EXIT_FAILURE; 127 137 } 128 138
Note: See TracChangeset
for help on using the changeset viewer.