5 ms·
> With C you can easily get better (that is, safer) than C++ native MM just building a reference counting system on top of your C "objects". Why build your own
by alpatters 14y ago
> With C you can easily get better (that is, safer) than C++ native MM just building a reference counting system on top of your C "objects".
Why build your own when C++ has std::shared_ptr.
- antirez 14y agoI was referring about how to do it with C.
- muks 14y agoHi antirez C doesn't have a destructor that gets called when something goes out of scope. That's taken advantage of in C++ (RAII) to implement various things (like scoped_ptr that helps avoid leaks). Refcounting is also not perfect for every case. But I like and prefer C. ;) Just pointing out one thing different in C++.
- thwest 14y agoHow is a C implementation of std::shared_ptr safer?