in reply to Managing C library memory in XS
As long as you always know that something returned by record_get_person may not be freed by your program, you can attack the problem by having two classes, Person::OwnedByPerl and Person::OwnedByLibrary. The destructor for Person::OwnedByPerl would call free_person(), while Person::OwnedByLibrary would have no destructor.
Of course, you could also store that information of whether to free the person or not on the XS level by having a struct hold the person pointer and a flag whether the XS owns that person or not.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Managing C library memory in XS
by petermogensen (Sexton) on May 05, 2014 at 13:27 UTC | |
by Corion (Patriarch) on May 05, 2014 at 13:34 UTC | |
by petermogensen (Sexton) on May 05, 2014 at 13:51 UTC | |
by Corion (Patriarch) on May 05, 2014 at 13:56 UTC | |
|
Re^2: Managing C library memory in XS
by ikegami (Patriarch) on May 05, 2014 at 20:56 UTC |