Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider following program. Note that execution begins at main. (Dont worry about what the program actually does . You will be studying where the variables

Consider following program. Note that execution begins at main. (Dont worry about what the program actually does. You will be studying where the variables are allocated.)

int *a, *e;

int c=4;

void DoFunctionB(int in1, int* in2) {

int f=6;

f++; // Accesses the local variable

in2 = malloc(500 * sizeof(int*)); // Dynamically allocate some int*s

*in2 = in1;

}

int DoFunctionA(int in1, int* in2) {

int *g;

DoFunctionB(in1++,in2++); // Call DoFunctionB with the passed-in args

g = in2;

return(in1);

}

void main( void ) {

int b=0;

int *d;

d = malloc(100 * sizeof(int)); // Dynamically allocate some ints

e = malloc(100 * sizeof(int)); // Dynamically allocate some ints

b = DoFunctionA(c,a); // Pass some variables into DoFunctionA

// note use of a and c

}

Assume that an int and an int * are both 4 bytes (32 bits) in size. When DoFunctionB is running (and its call to malloc has been made), how much space is in use in RAM? Break down the usage by the statically allocated RAM area, the heap, and the stack.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

7. What traps should she avoid?

Answered: 1 week ago

Question

5. What decision-making model would you advocate to this person?

Answered: 1 week ago

Question

6. What data will she need?

Answered: 1 week ago