Hello! If you're interested in doing some 1917 revision before the exam, I'll be holding a revision tutorial at 1pm on Tuesday, 1st November. For now I'll set the location to be Kora lab, end of the hallway on Level 3 of Mechanical Engineering (J17). Depending on how many people show up we may want to change rooms, and I'll update this page if that's the case.
Please bring along questions or topics you're unsure about, because otherwise we'll spend all the time trying to figure out what we should do :)
Sorry for the last minute change; I've moved the room to Flute because there's a few people in Kora and I'd prefer not to disturb people if possible. Same floor, same time, just in Flute (near the lifts) instead.
Revision Youtube Video Note: There may be content in here which is no longer relevant!
free()on the returned pointer. Failing to do so causes a "memory leak", where the operating system isn't made aware that we're no longer using a piece of memory, and never allocates it to anybody else.
createArray()returns a pointer to a local array. However, when the function ends, the memory associated with it is free to be used by other functions. This means that the values of the array may change when we access it later! Instead, we should use
malloc()to put the array in the heap, and manage the memory ourself.
gcc -Wall -Werror -O -o testPoint testPoint.c Point.c
Try to come up with some of your own tests for the functions provided; let me know if you find any bugs :)
Question 7, regarding alternative implementations, isn't answered here; we'll see it reappear in the next tutorial.
Enjoy the break!
I haven't tested this code extensively, so be sure to try out some operations yourself!
I made a couple of modifications to the interface suggested by the tutorial to allow for some edge cases
gcc -Wall -Werror -o testQueue ArrayQueue.c testQueue.c
gcc -Wall -Werror -o testQueue LinkedListQueue.c testQueue.c