diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2007-03-27 18:07:52 +0300 |
---|---|---|
committer | H.Merijn Brand <h.m.brand@xs4all.nl> | 2007-03-27 12:30:11 +0000 |
commit | 19a94d75aea23d860dc398284bf0810d3e2bbfa2 (patch) | |
tree | abd158e3b58402c2c78f68aea12fb4a6ca4e40cb /handy.h | |
parent | d3df0cfdbd533cd6ac647744531e0fed3b26c653 (diff) | |
download | perl-19a94d75aea23d860dc398284bf0810d3e2bbfa2.tar.gz |
stop the cargo cult of (MEM_SIZE)~0
Message-Id: <200703271207.l2RC7qOC443040@kosh.hut.fi>
p4raw-id: //depot/perl@30774
Diffstat (limited to 'handy.h')
-rw-r--r-- | handy.h | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -685,16 +685,18 @@ PoisonWith(0xEF) for catching access to freed memory. #define NEWSV(x,len) newSV(len) #endif +#define MEM_SIZE_MAX ((MEM_SIZE)~0) + /* The +0.0 in MEM_WRAP_CHECK_ is an attempt to foil * overly eager compilers that will bleat about e.g. * (U16)n > (size_t)~0/sizeof(U16) always being false. */ #ifdef PERL_MALLOC_WRAP #define MEM_WRAP_CHECK(n,t) MEM_WRAP_CHECK_1(n,t,PL_memory_wrap) #define MEM_WRAP_CHECK_1(n,t,a) \ - (void)(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > ((MEM_SIZE)~0)/sizeof(t) && (Perl_croak_nocontext(a),0)) + (void)(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > MEM_SIZE_MAX/sizeof(t) && (Perl_croak_nocontext(a),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-1+PERL_STRLEN_ROUNDUP_QUANTUM)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1))) +#define PERL_STRLEN_ROUNDUP(n) ((void)(((n) > MEM_SIZE_MAX - 2 * PERL_STRLEN_ROUNDUP_QUANTUM) ? (Perl_croak_nocontext(PL_memory_wrap),0):0),((n-1+PERL_STRLEN_ROUNDUP_QUANTUM)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1))) #else |