CSC209H1 Lecture Notes - Lecture 5: C Dynamic Memory Allocation, Call Stack
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.