Also, why does your code call u8_strlen when you already have the length?
For the rest (33K mallocs, 24K frees), I'm guessing perl doesn't bother to deeply free every data structure as it exits, since that would just waste time when the OS will clean it up anyway.
Update
Also, I suspect you should be using SvPVutf8 instead of SvPVbyte. The comment that "strings from my editor are already utf8 encoded" probably means that perl sees your strings as a string of bytes which *happen* to be utf-8 byte sequences, and that probably isn't what you want. Unicode handling in Perl can get very confusing because Perl requires the programmer to keep track of which strings are bytes and which are unicode, and also keep track of which APIs expect to receive bytes or strings of unicode. If you want to type unicode string literals and have perl understand them as unicode text, you should declare "use utf8;" at the top of your script. Otherwise you have declared an array of bytes, and if you pass that to an API expecting unicode, your strings could get double-encoded.
Back to your XS method, using SvPVbyte means that your XS library API needs to document that it operates on "byte strings which are expected to be a valid utf-8 encoding". Maybe this is what you want? but it will crash if a user passes it perl's understanding of unicode, e.g. uppercase_utf8_2("\x{100}").
And finally, I'm curious how this library is an improvement over perl's own 'uc' operator. Does perl incorrectly handle some cases?
In reply to Re: Memory Leak with XS but not pure C
by NERDVANA
in thread Memory Leak with XS but not pure C
by FrankFooty
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |