Skip to content
Browse files

do mixture of read/write on mem pages

  • Loading branch information...
1 parent 920e87e commit f7c75ef23d3889cd6e4007385c9d1a0c16fcf460 @poelzi committed Mar 24, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 tests/memleak.c
View
9 tests/memleak.c
@@ -26,6 +26,8 @@
#include <stdlib.h>
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+
int
main (argc, argv)
int argc;
@@ -125,7 +127,7 @@ main (argc, argv)
void **ptr = malloc(sizeof(void *) * nums);
void *ttmp;
-
+ char cmp[10] = "iutare29i3";
printf ("malloc %d chunks of %d kb (delay %d us):\n", nums, chunk, delay);
@@ -141,7 +143,10 @@ main (argc, argv)
if(stress) {
for(j = 0; i/3 < j; j++) {
ttmp = ptr[rand()%i];
- memset(ttmp + (rand()%chunk) - sizeof(int) , rand(), sizeof(int));
+ if(rand()%6 == 1)
+ memset(ttmp + (rand()%chunk) - sizeof(int) , rand(), sizeof(int));
+ else
+ memcmp(ttmp + (rand()%chunk) - MIN(10, chunk), cmp, MIN(10, chunk));
}
}
usleep(delay);

0 comments on commit f7c75ef

Please sign in to comment.
Something went wrong with that request. Please try again.