MHB Separating a List: What to Do After Deallocating?

  • Thread starter Thread starter mathmari
  • Start date Start date
  • Tags Tags
    List
AI Thread Summary
When deleting a list from an array of linked-lists, it is essential to deallocate all nodes of the list to ensure proper memory management. After deallocating the nodes, the corresponding entry in the array should be set to NULL to indicate that there is no longer a list attached to that position. If the array itself is not dynamically allocated, no further action is required regarding the array. This process ensures a clean removal of the list and helps prevent memory leaks.
mathmari
Gold Member
MHB
Messages
4,984
Reaction score
7
Hey! :o

When I have to delete a list from an array of linked-lists, do I have to delete all the nodes of the list? Or do I have to do also something at the array??

There is a list, I have to separate this list into two others and delete the initial list from the array.

I used a function to deallocate the list. What else should I do?? (Wondering)
 
Technology news on Phys.org
mathmari said:
Hey! :o

When I have to delete a list from an array of linked-lists, do I have to delete all the nodes of the list? Or do I have to do also something at the array??

There is a list, I have to separate this list into two others and delete the initial list from the array.

I used a function to deallocate the list. What else should I do?? (Wondering)

Hi! (Blush)

To destroy everything cleanly, we should iterate over the array, and iterate over each list in the array, deallocating the nodes as we go. Then the corresponding entry in the array should be set to NULL to indicate there is no list attached to it anymore. (Nerd)

There is nothing else to do with the array (assuming it was not dynamically allocated).
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top