in reply to Re: readonly access to C-level strings
in thread readonly access to C-level strings

What I want to avoid is exactly this copying. The strings are located in a mem segment that is mmapped read-only. So, there is no way for them to be changed and hence no need to be copied.
  • Comment on Re^2: readonly access to C-level strings

Replies are listed 'Best First'.
Re^3: readonly access to C-level strings
by ikegami (Patriarch) on Jul 02, 2009 at 16:20 UTC

    hence no need to be copied.

    No, there is a need: For Perl to see them.

    The buffers of Perl strings are subject to modification and freeing at any time. It *might* be possible to tell Perl the PV associated with a scalar can't be changed, but

    • there's no way to tell Perl to use a existing memory block for the string buffer of a string, and
    • there's no way to tell Perl the string buffer of a string can't be freed.