diff options
Diffstat (limited to '')
| -rw-r--r-- | lmem.c | 9 |
1 files changed, 5 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmem.c,v 1.12 1999/02/25 21:07:26 roberto Exp roberto $ | 2 | ** $Id: lmem.c,v 1.13 1999/02/26 15:50:10 roberto Exp roberto $ |
| 3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -39,7 +39,10 @@ static unsigned long power2 (unsigned long n) { | |||
| 39 | void *luaM_growaux (void *block, unsigned long nelems, int inc, int size, | 39 | void *luaM_growaux (void *block, unsigned long nelems, int inc, int size, |
| 40 | char *errormsg, unsigned long limit) { | 40 | char *errormsg, unsigned long limit) { |
| 41 | unsigned long newn = nelems+inc; | 41 | unsigned long newn = nelems+inc; |
| 42 | if ((newn ^ nelems) > nelems) { /* cross a power of 2 boundary? */ | 42 | if ((newn ^ nelems) <= nelems || /* still the same power of 2 limit? */ |
| 43 | (nelems > 0 && newn < MINSIZE)) /* or block already is MINSIZE? */ | ||
| 44 | return block; /* do not need to reallocate */ | ||
| 45 | else { /* it crossed a power of 2 boundary; grow to next power */ | ||
| 43 | if (newn >= limit) | 46 | if (newn >= limit) |
| 44 | lua_error(errormsg); | 47 | lua_error(errormsg); |
| 45 | newn = power2(newn); | 48 | newn = power2(newn); |
| @@ -47,8 +50,6 @@ void *luaM_growaux (void *block, unsigned long nelems, int inc, int size, | |||
| 47 | newn = limit; | 50 | newn = limit; |
| 48 | return luaM_realloc(block, newn*size); | 51 | return luaM_realloc(block, newn*size); |
| 49 | } | 52 | } |
| 50 | else | ||
| 51 | return block; | ||
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | 55 | ||
