3 ms·
The Linux kernel uses manual ref-counting in C. Ref-counting in C++ with smart pointers is much more robust. It can also be partially optimized. You can use c
by kazinator 10y ago
The Linux kernel uses manual ref-counting in C.
Ref-counting in C++ with smart pointers is much more robust.
It can also be partially optimized. You can use const references to pass smart pointers into helper functions, which means that the refcounts don't have to be bumped.
You can do that sort of thing manually too, but then you hav e to be careful about tracking which functions are sharing ownership with the caller (and so must not drop a reference, nor allow the reference to "escape").