CSC209H1 Lecture Notes - Lecture 8: Null Pointer, Uninitialized Variable, Dangling Pointer
Document Summary
Pointers solve two common problems: allow different sections of code to share information, without copying it, enable complex linked data structures like linked lists and binary trees. We pay a price for using pointers though. 5 common types of bugs: using uninitialized memory bad pointer. 2. trespassing on someone else"s memory over ow. 3. loosing pointer to memory storage memory leak. 4. irresponsible function callers memory leak: accessing memory declared as free dangling pointer. Referencing: int i = 8; int *ip; ip = &i; int **ipp; ipp = &ip; *ipp = ip is 16 ipp is 128. Freshly declared variables are initialized to whatever junk value was present i n the location that the memory contained. We never declare the location in memory that ageptr points to. So when we try to set it to 1234, we actually set the location of where the pointer should be to 1234. This will access some random memory, and destroy it.