CSC209H1 Lecture Notes - Lecture 5: C Dynamic Memory Allocation, Call Stack

70 views2 pages
27 Feb 2019
School
Course
Professor

Document Summary

Csc209h worksheet: malloc basics: each time a variable is declared or memory is otherwise allocated, it is important to understand how much memory is allocated, where it will be allocated and when it will be de-allocated. Complete the table below. (note: some of the programs allocate more than one block of memory. ) *i = malloc(sizeof(int)*7); int main() { int *i; fun(&i); free(i); int sireofcia v int. De-allocated when? sizeof(int) stack frame for main when program ends ciuofcfc. at whenfunreturns. Iomwtx achar notstring main char int ima i. I fun returns progeny progends frog e u turn prog v prog untiltrieswh. 1 cutsfree trees prog main i u turn main main heap u turn. Csc209h worksheet: malloc basics: trace the memory usage for the program below up to the point when initialize is about to return. We have set up both stack frames for you, and the location of the heap. Heap stack frame for initialize stack frame for main numbers"t.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents