diff options
author | Richard Leach <richardleach@users.noreply.github.com> | 2022-11-08 23:40:06 +0000 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2022-11-21 12:40:10 +0100 |
commit | dbf3614df92e720a9536b1cceb915a18ff2b8c08 (patch) | |
tree | 4a024e221c8ca84b8bbb14be28ebd890f7ffd610 /perl.h | |
parent | b17e77fbd875a907749400afcdb9da990643edad (diff) | |
download | perl-dbf3614df92e720a9536b1cceb915a18ff2b8c08.tar.gz |
Extract minimum PV buffer/AV element size to common definitions
In a nutshell, for a long time the minimum PV length (hardcoded
in Perl_sv_grow) has been 10 bytes and the minimum AV array size
(hardcoded in av_extend_guts) has been 4 elements.
These numbers have been used elsewhere for consistency (e.g.
Perl_sv_grow_fresh) in the past couple of development cycles.
Having a standard definition, rather than hardcoding in multiple
places, is more maintainable. This commit therefore introduces
into perl.h:
PERL_ARRAY_NEW_MIN_KEY
PERL_STRLEN_NEW_MIN
(Note: Subsequent commit(s) will actually change the values.)
Diffstat (limited to 'perl.h')
-rw-r--r-- | perl.h | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -1593,6 +1593,23 @@ Use L</UV> to declare variables of the maximum usable size on this platform. #define MEM_SIZE Size_t +/* av_extend and analogues enforce a minimum number of array elements. + * This has been 4 elements (so a minimum key size of 3) for a long + * time, but the rationale behind this seems to have been lost to the + * mists of time. */ +#ifndef PERL_ARRAY_NEW_MIN_KEY +#define PERL_ARRAY_NEW_MIN_KEY 3 +#endif + +/* Functions like Perl_sv_grow mandate a minimum string size. + * This was 10 bytes for a long time, the rationale for which seems lost + * to the mists of time. However, since this does not correlate to what + * modern malloc implementations will actually return, it can be revised + * to be more appropriate. */ +#ifndef PERL_STRLEN_NEW_MIN +#define PERL_STRLEN_NEW_MIN 10 +#endif + /* Round all values passed to malloc up, by default to a multiple of sizeof(size_t) */ |