diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-14 16:33:29 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-14 16:33:29 -0200 |
| commit | 1b15206cf9aa7005fc3d48f78f60f66838f10eb5 (patch) | |
| tree | 00a96c96d331417ba781b605c6c10d8daae01938 /lmem.c | |
| parent | e6d56cd2d844174bd40af4c44c0f68e2115e5876 (diff) | |
| download | lua-1b15206cf9aa7005fc3d48f78f60f66838f10eb5.tar.gz lua-1b15206cf9aa7005fc3d48f78f60f66838f10eb5.tar.bz2 lua-1b15206cf9aa7005fc3d48f78f60f66838f10eb5.zip | |
many details + code redistribution
Diffstat (limited to 'lmem.c')
| -rw-r--r-- | lmem.c | 6 |
1 files changed, 3 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmem.c,v 1.20 1999/11/22 13:12:07 roberto Exp roberto $ | 2 | ** $Id: lmem.c,v 1.21 1999/11/29 16:38:48 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 | */ |
| @@ -31,10 +31,10 @@ void *luaM_growaux (lua_State *L, void *block, unsigned long nelems, | |||
| 31 | int inc, int size, const char *errormsg, unsigned long limit) { | 31 | int inc, int size, const char *errormsg, unsigned long limit) { |
| 32 | unsigned long newn = nelems+inc; | 32 | unsigned long newn = nelems+inc; |
| 33 | if (newn >= limit) lua_error(L, errormsg); | 33 | if (newn >= limit) lua_error(L, errormsg); |
| 34 | if ((newn ^ nelems) <= nelems || /* still the same power of 2 limit? */ | 34 | if ((newn ^ nelems) <= nelems || /* still the same power-of-2 limit? */ |
| 35 | (nelems > 0 && newn < MINPOWER2)) /* or block already is MINPOWER2? */ | 35 | (nelems > 0 && newn < MINPOWER2)) /* or block already is MINPOWER2? */ |
| 36 | return block; /* do not need to reallocate */ | 36 | return block; /* do not need to reallocate */ |
| 37 | else /* it crossed a power of 2 boundary; grow to next power */ | 37 | else /* it crossed a power-of-2 boundary; grow to next power */ |
| 38 | return luaM_realloc(L, block, luaO_power2(newn)*size); | 38 | return luaM_realloc(L, block, luaO_power2(newn)*size); |
| 39 | } | 39 | } |
| 40 | 40 | ||
