Question: 1. After the following code runs, there will be pointers to the heap from for(int i=0;i allocs[i]=malloc(i*2+128); if(i>0) *(void**)(allocs[i])=allocs[i-1]; } (A) .data or globals (B)

1. After the following code runs, there will be pointers to the heap from

for(int i=0;i

allocs[i]=malloc(i*2+128);

if(i>0)

*(void**)(allocs[i])=allocs[i-1];

}

(A) .data or globals

(B) heap

(C) stack

(D) nowhere

(E) .data or global, heap and stack

2.Where will there be pointers to the heap when gc() is called in the following code?

void* recursive_allocations(int i) {

void* ptr = malloc(i*100+128);

if (i==0) return ptr;

void *ptr2 = recursive_allocations(i-1);

if(i==50) {

gc();

printf("Recursive1: at depth 50, %zu, free %d, inuse %d ",heap_size(),free_chunks(),inuse_chunks());

}

return ptr;

}

(A) .data or globals

(B) heap

(C) stack

(D) nowhere

(E) .data or global, heap and stack

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!