Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Problem trying to use Device::USB

by gwadej (Chaplain)
on Jul 22, 2010 at 03:52 UTC ( #850762=note: print w/ replies, xml ) Need Help??


in reply to Problem trying to use Device::USB

I've just had to revisit the code after applying the patch that resulted from this conversation. I wanted to update this discussion in case someone else had a similar issue.

The patched code was resulting in segfaults for some people. After reading the discussion and looking at the code more carefully, I realized that the C code was using void* in two different situations and that the reported type problem was only an issue for one of them.

In C, it is not unusual to use void* for both an opaque pointer and for a generic buffer. However, when passing these through Inline::C, we get (and need) very different behaviors.

All of the opaque pointer cases needed to remain void*, since the Perl code can never look inside the structure to inspect it directly. More importantly, we need to be returning the exact same pointer, not a different pointer with the same data, so the conversion to/from an IV makes sense here.

On the other hand, any generic buffer that we are expecting the Perl code to inspect must be changed to a char* for the reasons outlined in this thread.

Unfortunately, the submitted patch confused these uses in the opposite direction of my original mistake. Thanks to all of you for helping me understand this aspect of Inline::C somewhat better.

G. Wade


Comment on Re: Problem trying to use Device::USB
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://850762]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-07-31 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (255 votes), past polls