Alright genuine plea of help, because I am retarded:
What's your way of destroying a linked list? Let's say it looks something like this:
struct list { struct *list next; char *junk; // allocated on heap }
I don't know why I'm having a panic attack over this, I'm trying to do this in a way that doesn't mean I have repeat code I've already written inside a function designed to destroy the list.
I could just constantly get the end of the list and free that element. It doesn't sound all that efficient but I'm like, trying to go ahead and free the elements as I walk the list. I don't know if that's how people do it.
@nyanide but real talk maybe just have a temp pointer to the next item in the list, set it to the next in current, free current, then set current to next
@nyanide that’s how i always see it done. Easier if you don’t use a linked list, they are not very efficient, but there are some cases where they can be worth it.
@nyanide@pwm you seem to worry alot about heavy coding concepts and the such includong in your business life. Im retty good at these things becauseof my manufacturing experience. Ushouldlook into it its a way of.reinventing the same process but more efficiwntly. U should listen to this in the background if u dont have time to watch it https://m.youtube.com/watch?v=GmEARqTY8TY&pp=ygUJc2l4IHNpZ21h U can do inSANE shit with it ask @boyperpia he legit knows
@nyanide oh easy then. You can either walk the list iteratively and keep a temp pointer so that you keep track of the next available node, or you can do it recursively and depth-first destroy. The iterative version is more space efficient but the recursive version gets your dick really hard so its basically neck and neck
@nyanide oh easy then. You can either walk the list iteratively and keep a temp pointer so that you keep track of the next available node, or you can do it recursively and depth-first destroy. The iterative version is more space efficient but the recursive version gets your dick really hard so its basically neck and neck (unless tail call recursion is implemented (it is (in which case they are equivalent)))