diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-06-01 20:46:02 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-06-01 20:46:02 +0000 |
commit | 1936d2a74fbc35dd0d6862386c9988d92bb8e6e0 (patch) | |
tree | 09a500b0d6951b724685d60716d06c2d8ac13770 /handy.h | |
parent | dfe4365adac588e79ad9eb543e18d4db0a1c81a2 (diff) | |
download | perl-1936d2a74fbc35dd0d6862386c9988d92bb8e6e0.tar.gz |
Round up all string length requests to malloc()/realloc() to the next
multiple of 4/8 bytes [sizeof(size_t)] on the assumption that malloc()
internally will quantise, and so we're going to use space that
otherwise would be wasted. Hopefully this will save realloc()ing.
p4raw-id: //depot/perl@24665
Diffstat (limited to 'handy.h')
-rw-r--r-- | handy.h | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -605,6 +605,8 @@ hopefully catches attempts to access uninitialized memory. (void)((n)>((MEM_SIZE)~0)/sizeof(t)?(Perl_croak_nocontext(a,b),0):0) #define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t), +#define PERL_STRLEN_ROUNDUP(n) ((void)(((n) > (MEM_SIZE)~0 - 2 * PERL_STRLEN_ROUNDUP_QUANTUM) ? (Perl_croak_nocontext(PL_memory_wrap),0):0),((n)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1))+PERL_STRLEN_ROUNDUP_QUANTUM) + #else #define MEM_WRAP_CHECK(n,t) @@ -612,8 +614,9 @@ hopefully catches attempts to access uninitialized memory. #define MEM_WRAP_CHECK_2(n,t,a,b) #define MEM_WRAP_CHECK_(n,t) -#endif +#define PERL_STRLEN_ROUNDUP(n) (((n)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1))+PERL_STRLEN_ROUNDUP_QUANTUM) +#endif #define New(x,v,n,t) (v = (MEM_WRAP_CHECK_(n,t) (t*)safemalloc((MEM_SIZE)((n)*sizeof(t))))) #define Newc(x,v,n,t,c) (v = (MEM_WRAP_CHECK_(n,t) (c*)safemalloc((MEM_SIZE)((n)*sizeof(t))))) |