summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-05-31 15:40:48 +0100
committerDavid Mitchell <davem@iabyn.com>2013-06-02 22:28:54 +0100
commit2ac8ff4bf339d781f96fdfabd34d199a7f9569da (patch)
treeb3e85c2a06111db3d204bb623c99317985977873 /perl.c
parent331b2dcc3fd1fd971f7a6ed1192c36ceaa0d6a88 (diff)
downloadperl-2ac8ff4bf339d781f96fdfabd34d199a7f9569da.tar.gz
eliminate PL_reg_poscache, PL_reg_poscache_size
Eliminate these two global vars (well, fields in the global PL_reg_state), that hold the regex super-liner cache. PL_reg_poscache_size gets replaced with a field in the local regmatch_info struct, while PL_reg_poscache (which needs freeing at end of pattern execution or on croak()), goes in the regmatch_info_aux struct. Note that this includes a slight change in behaviour. Each regex execution now has its own private poscache pointer, initially null. If the super-linear behaviour is detected, the cache is malloced, used for the duration of the pattern match, then freed. The former behaviour allocated a global poscache on first use, which was retained between regex executions. Since the poscache could between 0.25 and 2x the size of the string being matched, that could potentially be a big buffer lying around unused. So we save memory at the expense of a new malloc/free for every regex that triggers super-linear behaviour. The old behaviour saved the old pointer on reentrancy, then restored the old one (and possibly freed the new buffer) at exit. Except it didn't for (?{}), so /(?{ m{something-that-triggers-super-linear-cache} })/ would leak each time the inner regex was called. This is now fixed automatically.
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/perl.c b/perl.c
index 06953c6dbf..726f571614 100644
--- a/perl.c
+++ b/perl.c
@@ -1219,7 +1219,6 @@ perl_destruct(pTHXx)
Safefree(PL_origfilename);
PL_origfilename = NULL;
Safefree(PL_reg_curpm);
- Safefree(PL_reg_poscache);
free_tied_hv_pool();
Safefree(PL_op_mask);
Safefree(PL_psig_name);
@@ -3626,7 +3625,6 @@ S_init_interp(pTHX)
/* As these are inside a structure, PERLVARI isn't capable of initialising
them */
PL_reg_curpm = NULL;
- PL_reg_poscache = PL_reg_starttry = NULL;
}
STATIC void