Ap |I32 * |markstack_grow
#if defined(USE_LOCALE_COLLATE)
p |int |magic_setcollxfrm|NN SV* sv|NN MAGIC* mg
+p |int |magic_freecollxfrm|NN SV* sv|NN MAGIC* mg
pbD |char* |mem_collxfrm |NN const char* input_string|STRLEN len|NN STRLEN* xlen
: Defined in locale.c, used only in sv.c
# if defined(PERL_IN_LOCALE_C) || defined(PERL_IN_SV_C) || defined(PERL_IN_MATHOMS_C)
#define padnamelist_dup(a,b) Perl_padnamelist_dup(aTHX_ a,b)
# endif
# if defined(USE_LOCALE_COLLATE)
+#define magic_freecollxfrm(a,b) Perl_magic_freecollxfrm(aTHX_ a,b)
#define magic_setcollxfrm(a,b) Perl_magic_setcollxfrm(aTHX_ a,b)
#ifndef NO_MATHOMS
#define mem_collxfrm(a,b,c) Perl_mem_collxfrm(aTHX_ a,b,c)
if (vtbl && vtbl->svt_free)
vtbl->svt_free(aTHX_ sv, mg);
- if (mg->mg_type == PERL_MAGIC_collxfrm && mg->mg_len >= 0)
- /* collate magic uses string len not buffer len, so
- * free even with mg_len == 0 */
- Safefree(mg->mg_ptr);
- else if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
+ if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
if (mg->mg_len > 0 || mg->mg_type == PERL_MAGIC_utf8)
Safefree(mg->mg_ptr);
else if (mg->mg_len == HEf_SVKEY)
}
return 0;
}
+
+int
+Perl_magic_freecollxfrm(pTHX_ SV *sv, MAGIC *mg)
+{
+ PERL_ARGS_ASSERT_MAGIC_FREECOLLXFRM;
+ PERL_UNUSED_ARG(sv);
+
+ /* Collate magic uses mg_len as a string length rather than a buffer
+ * length, so we need to free even with mg_len == 0: hence we can't
+ * rely on standard magic free handling */
+ assert(mg->mg_type == PERL_MAGIC_collxfrm && mg->mg_len >= 0);
+ Safefree(mg->mg_ptr);
+ mg->mg_ptr = NULL;
+ return 0;
+}
#endif /* USE_LOCALE_COLLATE */
/* Just clear the UTF-8 cache data. */
{ 0, 0, 0, 0, Perl_magic_killbackrefs, 0, 0, 0 },
{ 0, 0, 0, 0, 0, Perl_magic_copycallchecker, 0, 0 },
#ifdef USE_LOCALE_COLLATE
- { 0, Perl_magic_setcollxfrm, 0, 0, 0, 0, 0, 0 },
+ { 0, Perl_magic_setcollxfrm, 0, 0, Perl_magic_freecollxfrm, 0, 0, 0 },
#else
{ 0, 0, 0, 0, 0, 0, 0, 0 },
#endif
#define PERL_ARGS_ASSERT__IS_CUR_LC_CATEGORY_UTF8
#endif
#if defined(USE_LOCALE_COLLATE)
+PERL_CALLCONV int Perl_magic_freecollxfrm(pTHX_ SV* sv, MAGIC* mg);
+#define PERL_ARGS_ASSERT_MAGIC_FREECOLLXFRM \
+ assert(sv); assert(mg)
PERL_CALLCONV int Perl_magic_setcollxfrm(pTHX_ SV* sv, MAGIC* mg);
#define PERL_ARGS_ASSERT_MAGIC_SETCOLLXFRM \
assert(sv); assert(mg)
'ovrld' => {free => 'freeovrld'},
'utf8' => {set => 'setutf8'},
'collxfrm' => {set => 'setcollxfrm',
+ free => 'freecollxfrm',
cond => '#ifdef USE_LOCALE_COLLATE'},
'hintselem' => {set => 'sethint', clear => 'clearhint'},
'hints' => {clear => 'clearhints'},