And the problem is that I can't see when I get a "person" pointer I get back in DESTROY whether I'm allowed to free it.
This is the key paragraph and decision point in the code. You should wrap the real free_person() in XS function that would have the logic like this:
Then from Perl just call this wrapper and let the lower-level logic worry about it.if (person_refcnt(person) == 0) free_person(person); else ; /* Do nothing: free_record() will free the person as well */
In reply to Re: Managing C library memory in XS
by dmitri
in thread Managing C library memory in XS
by petermogensen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |