Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Maybe I'm wrong about this but I noticed that the code didn't call free() to the element that has breen removed. That would cause a memory leak. Am I missing something here?


The caller still holds a pointer to the element and can free it. I would argue that delegating the responsibility of freeing the element to the caller is more performant, since that allows the code to reuse that list element and insert it into a different (compatible) list.

That's the kind of performance/ease-of-use trade-off that sounds reasonable in an open source project with strict code reviews (but in very few other places)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: