File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -3395,7 +3395,10 @@ do
3395
3395
}
3396
3396
else
3397
3397
{
3398
+ import core.memory : pureMalloc, pureFree;
3398
3399
C[] pattmp;
3400
+ scope (exit) if (pattmp ! is null ) (() @trusted => pureFree(pattmp.ptr))();
3401
+
3399
3402
for (size_t pi = 0 ; pi < pattern.length; pi++ )
3400
3403
{
3401
3404
const pc = pattern[pi];
@@ -3481,9 +3484,12 @@ do
3481
3484
* pattern[pi0 .. pi-1] ~ pattern[piRemain..$]
3482
3485
*/
3483
3486
if (pattmp is null )
3487
+ {
3484
3488
// Allocate this only once per function invocation.
3485
- // Should do it with malloc/free, but that would make it impure.
3486
- pattmp = new C[pattern.length];
3489
+ pattmp = (() @trusted =>
3490
+ (cast (C* ) pureMalloc(C.sizeof * pattern.length))[0 .. pattern.length])
3491
+ ();
3492
+ }
3487
3493
3488
3494
const len1 = pi - 1 - pi0;
3489
3495
pattmp[0 .. len1] = pattern[pi0 .. pi - 1 ];
3517
3523
}
3518
3524
3519
3525
// /
3520
- @safe unittest
3526
+ @safe @nogc unittest
3521
3527
{
3522
3528
assert (globMatch(" foo.bar" , " *" ));
3523
3529
assert (globMatch(" foo.bar" , " *.*" ));
You can’t perform that action at this time.
0 commit comments