I am confused by the {}
inside the main
. Can someone please explain me their purpose? I do understand the code, but this is the first time I see this format.
Why are the {}
necessary to this part of the code, or what is the use of {}
inside a function? It is not to declare a nested function, or is it?
int main()
{
void *p1, *p2, *p3;
arenaCheck();
p1 = malloc(254);
arenaCheck();
p2 = malloc(25400);
arenaCheck();
p3 = malloc(254);
printf("%llx %llx %llx\n", (long long)p1, (long long)p2, (long long)p3);
arenaCheck();
free(p2);
arenaCheck();
free(p3);
arenaCheck();
free(p1);
arenaCheck();
{ /* What is the purpose of these, what is this doing { } */
struct timeval t1, t2;
int i;
getutime(&t1);
for(i = 0; i < 10000; i++)
if (malloc(4) == 0)
break;
getutime(&t2);
printf("%d *** malloc(4) required %f seconds\n", i, diffTimeval(&t2,&t1));
}
return 0;
}