I\'m using Word-Net, an old C library developed by Princeton University back in the nineties. The library is written in C, and only reveals the headers but not its actual implem
You can use std::shared_ptr
for this purpose, as you can provide the deleter to use to free the pointer.
std::shared_ptr findTheInfo(...) {
std::shared_ptr sp(findtheinfo(...), free_syns);
return sp;
}
std::shared_ptr tracePtrs(...) {
std::shared_ptr sp(traceptrs(...), free_synset);
return sp;
}
Now, if they really represent different things, you might want to spend a bit more effort and provide two types that wrap each use and provide the appropriate interface. Does it make sense to treat both as the same type when transversing a list and a tree might be completely different?