5 ms·
Linked lists are complicated. You can get something that compiles easily with C++, but to be sure it doesn't leak memory might require you to get that PhD after
by karmakurtisaani 4y ago
Linked lists are complicated. You can get something that compiles easily with C++, but to be sure it doesn't leak memory might require you to get that PhD after all.
- pclmulqdq 4y agoLinked lists are a very simple data structure, and pretty much everyone can get them right. There haven't been any big memory safety CVEs to my knowledge around linked list manipulation. The same for binary trees. These pointer-based data structures are used a lot when you are manipulating large structs in C and C++, as they let you "move" then between data structures without copying a ton of memory.
- planede 4y agoIt's not exactly rocket science or even PhD worthy, but getting basic exception safety right around manual memory management can get tricky.
- lenkite 4y agoWell..implementing them in "safe" Rust is not just tricky - it requires a super-brain.
- eru 4y agoYou can use unsafe in Rust to get basically the same guarantees for your simple linked list as in C++?
- jcdentonunatco 4y agoIf you need a PhD to avoid memory leaks, stop coding immediately, you don’t know what you are doing
- pebal 4y agoShow an example of a lock-free concurrent stack freeing nodes memory.