I think we should introduce new APIs to increment/decrement the ref value of a Sdb. This can be very useful in radare2 where sdb are passed around and sometimes it's not clear which component will be the first to release a given Sdb.
This seems the case with RBinFile, which has a ->sdb field which is not freed in r_bin_file_free because it is already freed by someone else. This leads to memory leaks in some cases and in general I think it is not good practice to have some fields of a data structure owned by something else.
I think we should introduce new APIs to increment/decrement the ref value of a Sdb. This can be very useful in radare2 where sdb are passed around and sometimes it's not clear which component will be the first to release a given Sdb.
This seems the case with RBinFile, which has a
->sdbfield which is not freed inr_bin_file_freebecause it is already freed by someone else. This leads to memory leaks in some cases and in general I think it is not good practice to have some fields of a data structure owned by something else.