in reply to (tye)Re: Passing reference to perl from C code
in thread Passing reference to perl from C code

Hi Tye, Yes, You are correct. Thanks. We have to copy the string (using XPUSH) into perl stack. Our problem will be like this, we have to call the perl subroutine with some 200 to 300 string of huge size during every invocation. Please see the below C code used to call the perl subroutine.
please note that the macros are not in the order. dSP; SAVETEMPS; PUSKMARK; XPUSHs(SV equivalent for the First string); XPUSHs(SV equivalent for the second string); : : : XPUSHs(SV equivalent for the Nth string); call_pv("pkg1::Process",G_SCALAR); something goes here
If we have something like passing the address of the strings as in the C calls
void Process(char *p) { // some processing } main() { char Str[500]; strcpy(Str,"slkdjaslkdjsljdlkjas"); Process(&Str);
Is there any way to push the address of the string using XPUSHs() and that string can be used by the perl script?. Regards, Poorna

Replies are listed 'Best First'.
(tye)Re2: Passing reference to perl from C code
by tye (Sage) on Dec 21, 2000 at 22:10 UTC

    Is there any way to push the address of the string using XPUSHs() and that string can be used by the perl script?

    I suggest you reread my previous reply as you don't appear to have understood it. The answer is "no". The best you can do is not recreate the SV equivalent of each string over and over.

            - tye (but my friends call me "Tye")