This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl_alloc_using() should use ->pCalloc
authorNicholas Clark <nick@ccl4.org>
Mon, 20 Sep 2021 15:04:29 +0000 (15:04 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 28 Sep 2021 06:12:27 +0000 (06:12 +0000)
Use ->pCalloc  instead of ->pMalloc followed by Zero()

This commit is analogous to the change in perl_alloc() in the previous
commit - the order of S_init_tls_and_interp() and Zero() can be swapped,
at which point the change to use "calloc" is obvious.

perl.c

diff --git a/perl.c b/perl.c
index c9807b7..8beb5d0 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -159,9 +159,8 @@ perl_alloc_using(struct IPerlMem* ipM, struct IPerlMem* ipMS,
     PERL_ARGS_ASSERT_PERL_ALLOC_USING;
 
     /* Newx() needs interpreter, so call malloc() instead */
-    my_perl = (PerlInterpreter*)(*ipM->pMalloc)(ipM, sizeof(PerlInterpreter));
+    my_perl = (PerlInterpreter*)(*ipM->pCalloc)(ipM, 1, sizeof(PerlInterpreter));
     S_init_tls_and_interp(my_perl);
-    Zero(my_perl, 1, PerlInterpreter);
     PL_Mem = ipM;
     PL_MemShared = ipMS;
     PL_MemParse = ipMP;