'Multipurpose' linked list implementation in pure C

前端 未结 9 1800
一生所求
一生所求 2020-12-12 16:33

This is not exactly a technical question, since I know C kind of enough to do the things I need to (I mean, in terms of not \'letting the language get in your way\'), so thi

9条回答
  •  北海茫月
    2020-12-12 17:23

    I've done this in the past, in our code (which has since been converted to C++), and at the time, decided on the void* approach. I just did this for flexibility - we were almost always storing a pointer in the list anyways, and the simplicity of the solution, and usability of it outweighed (for me) the downsides to the other approaches.

    That being said, there was one time where it caused some nasty bug that was difficult to debug, so it's definitely not a perfect solution. I think it's still the one I'd take, though, if I was doing this again now.

提交回复
热议问题