Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

In reply to Re: Problem trying to use Device::USB by gwadej
in thread Problem trying to use Device::USB by scliffe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-24 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found