File:  [CSRG BSD Unix] / 43BSD / undoc / brktest.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

	int	a[1000];

main()
{
	int	asize = 1000,i,inc = 0,new;

	srand(1);
	for (i = 0 ; i < asize ; i++)
		a[i] = i;
	while (1)  {
		new = rand() % 4000;
		if (((rand() % 1000) > 750) && ((asize - new) > 1000))
			new = -new;
		for (i = 0 ;  i < asize ; i++ )
			if (a[i] != i)
				printf("bad a %x\n",i);
			if (sbrk(4 * new) != -1)  {
				if (new > 0)  {
					for (i = 0 ; i < new ; i++)
						a[asize + i] = asize + i;  }
				asize += new;  }
			else  {
				new = 1000 - asize;
				sbrk(4 * new);
				asize += new;  }
		sleep((rand() % 4) + 1);  }
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.