Jakub Narębski [off-list ref] writes:
quoted
We manage lifetime of a field in a structure in one of three ways in
our codebase [*1*].
...
* A field can sometimes own and sometimes borrow the memory, and it
is accompanied by another field to tell which case it is, so that
cleaning-up can tell when it needs to be free(3)d. This is a
minority case, and we generally avoid it especially in modern
code for small allocation, as it makes the lifetime rule more
complex than it is worth.
...
On the other hand the _entrust() mechanism might be a good solution
if the amount of memory was large, for example order of magnitude more
than what would be needed to keep ownership info *and* borrowing would
not be possible for some reason.
We have approach #3 exactly for that usage pattern.