Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
do mixture of read/write on mem pages
  • Loading branch information
poelzi committed Mar 23, 2011
1 parent 920e87e commit f7c75ef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/memleak.c
Expand Up @@ -26,6 +26,8 @@

#include <stdlib.h>

#define MIN(a, b) (((a) < (b)) ? (a) : (b))

int
main (argc, argv)
int argc;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit f7c75ef

Please sign in to comment.