|
|
|
|
|
by arjun-menon
2025 days ago
|
|
That does make it a bit clearer, but I do hope the compiler optimizes away the redundant curr variable. Now, on a different note, I am a bit puzzled because I don’t see a free(*ptr) call in Linus’ or anyone else’s code. The code, as-is, would cause a memory leak. There’s a need to capture the curr_ref before it’s overwritten, and free it after it’s overwritten. |
|
So generally, list implementations in C will not free the node, only remove references to it and return it.