diff options
| -rw-r--r-- | lauxlib.c | 10 |
1 files changed, 8 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.161 2006/09/18 14:03:18 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.162 2006/09/22 20:24:38 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -25,7 +25,11 @@ | |||
| 25 | #include "lauxlib.h" | 25 | #include "lauxlib.h" |
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | #define FREELIST_REF 0 /* free list of references */ | 28 | /* number of prereserved references (for internal use) */ |
| 29 | #define RESERVED_REFS 1 /* only FREELIST_REF is reserved */ | ||
| 30 | |||
| 31 | #define FREELIST_REF 1 /* free list of references */ | ||
| 32 | |||
| 29 | 33 | ||
| 30 | 34 | ||
| 31 | /* convert a stack index to positive */ | 35 | /* convert a stack index to positive */ |
| @@ -494,6 +498,8 @@ LUALIB_API int luaL_ref (lua_State *L, int t) { | |||
| 494 | } | 498 | } |
| 495 | else { /* no free elements */ | 499 | else { /* no free elements */ |
| 496 | ref = (int)lua_objlen(L, t); | 500 | ref = (int)lua_objlen(L, t); |
| 501 | if (ref < RESERVED_REFS) | ||
| 502 | ref = RESERVED_REFS; /* skip reserved references */ | ||
| 497 | ref++; /* create new reference */ | 503 | ref++; /* create new reference */ |
| 498 | } | 504 | } |
| 499 | lua_rawseti(L, t, ref); | 505 | lua_rawseti(L, t, ref); |
