Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Re: Passing a very large string by reference to a c library

by dino (Sexton)
on Jul 12, 2001 at 18:37 UTC ( [id://96050]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Passing a very large string by reference to a c library
in thread Passing a very large string by reference to a c library

I've got it to work with:

unsigned long
find_index (key, data)
        unsigned long         key
        SV    *               data
    INIT:
       STRLEN          datalen;
       char * s;
       if ((!SvROK(data))
          || (SvTYPE(SvRV(data)) != SVt_PV))
       {
          XSRETURN_UNDEF;
       }
       s = SvPV(SvRV(data), datalen);
    CODE:
      RETVAL = find_index (key, s, datalen);
    OUTPUT:
      RETVAL

I'm still not sure if SvPV copies its internal data somewhere or just returns a pointer to it.

Comments please

dino

Replies are listed 'Best First'.
Re: Re: Re: Re: Passing a very large string by reference to a c library
by dino (Sexton) on Jul 12, 2001 at 20:03 UTC
    And finally,

    from the perlapi manpage:

     SvPV    Returns a pointer to the string in the SV, or a
             stringified form of the SV if the SV does not con-
             tain a string.  Handles 'get' magic.
     
             char*   SvPV(SV* sv, STRLEN len)
    

    so that should do it

    dino

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found