Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I'm guessing based on the C parts since I don't know XS very well.

    Aren't you calloc()ing a char buffer without free()ing it.

    • Yes, but perl should free that when the SvREFCOUNT reaches zero.
      • Never mind, that does indeed appear to be the culprit. How strange - I could have sworn perl free'd the strings.
        • The string (ret) is copied from the svpv, and not maintained by any sv so it's not perl's responsibility to manage the memory allocated to it.
          • What's weird is this pretty much guarantees that a char * typemap will leak (as you can't free it before you return) unless you are returning static char *s.
            • Why are you returning a char * anyway? Why dont you return an SV? Something like this untested version of your code. Also doing *foo++; is pretty misleading since its the same as foo++;.

              SV *
                      SV * str
                              STRLEN len;
                              char *cval = SvPV(str, len);