3 ms·
How does this work for a case like DOM nodes? Where each child is constantly re-assigned parents? Is there any way to reset the parent?
by dhruvbird 15y ago
How does this work for a case like DOM nodes? Where each child is constantly re-assigned parents? Is there any way to reset the parent?
- bluetech 15y agoYes, and you can also have multiple parents with a reference-count semantics. void * talloc_steal(const void * new_ctx, const void * ptr); The talloc_steal() function changes the parent context of a talloc pointer. It is typically used when the context that the pointer is currently a child of is going to be freed and you wish to keep the memory for a longer time. NOTE: It is possible to produce loops in the parent/child relationship if you are not careful with talloc_steal(). No guarantees are provided as to your sanity or the safety of your data if you do this. There's also talloc_reparent where you explicitly choose the parent to change.
- dhruvbird 15y agoThis is nice!! Thanks!!