Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 4fc30d62c2a290a6dfdfe429ff18dfcbc97a4233
      
https://github.com/Perl/perl5/commit/4fc30d62c2a290a6dfdfe429ff18dfcbc97a4233
  Author: Nicholas Clark <[email protected]>
  Date:   2021-09-28 (Tue, 28 Sep 2021)

  Changed paths:
    M perl.c

  Log Message:
  -----------
  perl_alloc() wants zeroed memory so should use calloc()

The previous code

1) allocated memory with PerlMem_malloc()
2) passed the pointer to S_init_tls_and_interp()
3) called Zero() or ZeroD()
4) optionally invoked INIT_TRACK_MEMPOOL()
5) returned the pointer

ZeroD() and Zero() are equivalent, apart from the return value of the
expression.

The layers of functions and macros obscured what what was actually
happening, and what the ordering dependencies are:

* S_init_tls_and_interp() uses only the address of the pointer
* Zero() zeros the memory
* Only INIT_TRACK_MEMPOOL() touches the contents
* all the "memory wrap" macros inside the other macros can't "trigger"

Hence the order of Zero() and S_init_tls_and_interp() can be swapped,
at which point Zero() immediately follows malloc(), meaning that the two
should be be replaced with calloc().

This simplifies the function considerably.


  Commit: 53e57886af4cddfdf74c6a06e9a6995d07318806
      
https://github.com/Perl/perl5/commit/53e57886af4cddfdf74c6a06e9a6995d07318806
  Author: Nicholas Clark <[email protected]>
  Date:   2021-09-28 (Tue, 28 Sep 2021)

  Changed paths:
    M perl.c

  Log Message:
  -----------
  No need to wrap INIT_TRACK_MEMPOOL with #ifdef PERL_TRACK_MEMPOOL

`INIT_TRACK_MEMPOOL` is defined as a no-op if `PERL_TRACK_MEMPOOL` is not
defined, so no need to wrap it in `#ifdef`.

Spotted by Ilmari.


  Commit: 40385047d97eb13626cd69471b811bd8e751f665
      
https://github.com/Perl/perl5/commit/40385047d97eb13626cd69471b811bd8e751f665
  Author: Nicholas Clark <[email protected]>
  Date:   2021-09-28 (Tue, 28 Sep 2021)

  Changed paths:
    M perl.c

  Log Message:
  -----------
  perl_alloc_using() should use ->pCalloc

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.


Compare: https://github.com/Perl/perl5/compare/e36174629b92...40385047d97e

Reply via email to