in reply to XS: Manipulating refcounts
First of all note that I do not have much experience with C and/or XS.
So what I'm saying might make sense or not.
What you are doing is a bit dangerous... (Or atleast I think so).
You are creating an Artist and then creating a referenceto that artist (which s not a perl structure). So what you are doing is saving the pointer of *artist in $$artist.
This can easily go wrong... For example: $$artist = 0; or $$artitst--;. If you then call your C code then you will - most likely - get a segmentation fault because you cannot access that memory space...
I think a better way to do this would be to store the actual Artist object in an array or so in the C code and return an SV/RV with the index in the array.
So far for the artists, for the CDs I think it would be easier to store the SV (after incrementing it's reference count ofcourse), and not the Artist...
This would also eliminate the need to store the RV/SV in the Artist object...
At the moment I haven't played enough with the code to give you a full (and working) example of what I mean. (so consider this as some initial feedback - some of which might be incorrect)... I will try to do this later today
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XS: Manipulating refcounts
by Animator (Hermit) on Sep 20, 2006 at 11:19 UTC | |
by creamygoodness (Curate) on Sep 20, 2006 at 18:04 UTC | |
|
Re^2: XS: Manipulating refcounts
by creamygoodness (Curate) on Sep 20, 2006 at 16:20 UTC | |
by Animator (Hermit) on Sep 20, 2006 at 18:21 UTC | |
by creamygoodness (Curate) on Sep 20, 2006 at 19:11 UTC |