The pointer s_f to the object allocated by PutANDGate is overwritten in the third line and the corresponding object remains in memory without being used ever again.
If the user is responsible for the deallocation of the share objects, it should be noted in the developer guide and done in the examples applications.
A different (and in my eyes more pleasant) solution would be something like this:
Each time a gate is created via the
Put...Gate
, e.g.BooleanCircuit::PutXORGate(share*, share*)
, ashare
object is created.Following the examples and building a circuit like this results in memory leaks.
The pointer
s_f
to the object allocated byPutANDGate
is overwritten in the third line and the corresponding object remains in memory without being used ever again.If the user is responsible for the deallocation of the
share
objects, it should be noted in the developer guide and done in the examples applications.A different (and in my eyes more pleasant) solution would be something like this:
The created
boolshare
gets destroyed as soon as all copies of thestd::shared_ptr
are gone.