Author: Unknown
Subject: Memory in addD and pushD
Date: Wednesday, 18 Mar 2020, 10:32:27
I am currently debugging my Deque.c program. I have run gdb in detail and am currently focusing on addD and pushD. I displayed the first nodes of both linked lists throughout the program so I could observe their behaviors. When pushD is called on the even lines, a new node is create at the beginning of the H linked list. during that time, the memory at the first node of the T linked list "cannot be accessed." When addD is called on the odd lines, both first nodes' values are getting set to the string in question, instead of just the first node of the T list. There is no call to the H list at all inside of addD. I'm assuming this has something to do with creating local copies of variables that might not actually modify the deques, but I'm confused as to why that would happen if I am using pointers and allocating memory each time. I noticed that each time a node is created in addD and pushD, it has the same address, meaning that memory must have been freed without my doing so at the end of addD and pushD, and the nodes I've created are not actually getting stored? I am confused as to how to fix this memory problem.PREV INDEX NEXT