diff options
Diffstat (limited to 'src/mem5.c')
-rw-r--r-- | src/mem5.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mem5.c b/src/mem5.c index c194a6b77..02f4c2744 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -420,8 +420,17 @@ static void *memsys5Realloc(void *pPrior, int nBytes){ */ static int memsys5Roundup(int n){ int iFullSz; - if( n > 0x40000000 ) return 0; - for(iFullSz=mem5.szAtom; iFullSz<n; iFullSz *= 2); + if( n<=mem5.szAtom*2 ){ + if( n<=mem5.szAtom ) return mem5.szAtom; + return mem5.szAtom*2; + } + if( n>0x10000000 ){ + if( n>0x40000000 ) return 0; + if( n>0x20000000 ) return 0x40000000; + return 0x20000000; + } + for(iFullSz=mem5.szAtom*8; iFullSz<n; iFullSz *= 4); + if( (iFullSz/2)>=(i64)n ) return iFullSz/2; return iFullSz; } |