Assignment 2 Freeing Tree Memory

222 views
Skip to first unread message

Ryan Tio

unread,
Sep 16, 2020, 11:32:41 PM9/16/20
to cmpt-295-sfu
SFU ID: rtio
Github username: rtiosfu
Github: N/A
Line and file: N/A 
Expected behavior: N/A
Observed behavior: N/A
Question: I was wondering how we were supposed to deal with memory if we use the new_node function to build our trees. I used valgrind and I have an idea on how to free the memory, but I am unsure what I can edit to free the memory (What functions I am allowed to change)

Could it be in print_postorder()?

Arrvindh Shriraman

unread,
Sep 17, 2020, 12:40:32 AM9/17/20
to cmpt-295-sfu
You cannot change the arguments or return values of the functions we have specified, 
other than that you can add other functions to tree.c, but you cannot any more files.
Make sure you do not modify the calls we make i.e., you can add new code but cannot change or bypass any of our calls.

Arrvindh Shriraman

unread,
Sep 17, 2020, 12:40:57 AM9/17/20
to cmpt-295-sfu
PS: Please modify title to Ass 1 : Part 2. Not assignment 2.

Ryan Tio

unread,
Sep 17, 2020, 1:30:29 AM9/17/20
to cmpt-295-sfu
I don't think I can change the title, but I have changed the tags. 

Does this mean that I can add a line to the postorder function that cleans up the memory as long as it doesn't change the output?

ashrir...@gmail.com

unread,
Sep 17, 2020, 1:33:48 AM9/17/20
to cmpt-295-sfu
yes.

Ryan Tio

unread,
Sep 17, 2020, 1:48:11 AM9/17/20
to cmpt-295-sfu
Are the modifications I made to tree.c (at https://github.com/CMPT-295-SFU/assignment-1-rtiosfu/tree/master/Tree, lines 64 - 111) okay? I have retained a copy of the code before I made these adjustments in case it isn't. 

Arrvindh Shriraman

unread,
Sep 17, 2020, 11:38:19 AM9/17/20
to cmpt-295-sfu
Seems Ok! 
FYI; make sure you comment out your own printfs.
For this assignment you passed travis, but we cannot guarantee it on subsequent assignments if you add printfs when we have not indicated. 
  • You cannot and will not need to add any additional print statements (unless we have indicated you to)

------------------------
PS:  The whole point of git commits is to retain these copies, you can always revert back to a commit point. You do not need to make additional copies.
Reply all
Reply to author
Forward
0 new messages