Skip to content

Commit db43743

Browse files
committed
Added LUA_HEAP_PTR_T and LUA_HEAP_SIZE_T definitions to luaL_alloc.
1 parent baf0c63 commit db43743

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

lua.pat

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
--- lua/lauxlib.c
2+
+++ lua/lauxlib.c
3+
@@ -1046,7 +1046,10 @@ LUALIB_API const char *luaL_gsub (lua_State *L, const char *s,
4+
}
5+
6+
7+
-void *luaL_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
8+
+LUALIB_API LUA_HEAP_PTR_T *luaL_alloc (void *ud,
9+
+ LUA_HEAP_PTR_T *ptr,
10+
+ LUA_HEAP_SIZE_T osize,
11+
+ LUA_HEAP_SIZE_T nsize) {
12+
UNUSED(ud); UNUSED(osize);
13+
if (nsize == 0) {
14+
free(ptr);
15+
16+
--- lua/lauxlib.h
17+
+++ lua/lauxlib.h
18+
@@ -81,8 +81,9 @@ LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
19+
LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
20+
LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
21+
22+
-LUALIB_API void *luaL_alloc (void *ud, void *ptr, size_t osize,
23+
- size_t nsize);
24+
+LUALIB_API LUA_HEAP_PTR_T *luaL_alloc (void *ud, LUA_HEAP_PTR_T *ptr,
25+
+ LUA_HEAP_SIZE_T osize,
26+
+ LUA_HEAP_SIZE_T nsize);
27+
28+
29+
/* predefined references */
130
--- lua/lopcodes.h
231
+++ lua/lopcodes.h
332
@@ -78,8 +78,9 @@ enum OpMode {iABC, ivABC, iABx, iAsBx, iAx, isJ};
@@ -92,6 +121,7 @@
92121
#else
93122
#define l_system(cmd) system(cmd) /* default definition */
94123
#endif
124+
95125
--- lua/luaconf.h
96126
+++ lua/luaconf.h
97127
@@ -95,7 +95,12 @@
@@ -161,3 +191,22 @@
161191
#define LUA_DIRSEP "\\"
162192
#else
163193
#define LUA_DIRSEP "/"
194+
@@ -739,7 +770,18 @@
195+
** without modifying the main part of the file.
196+
*/
197+
198+
+/*
199+
+** Definitions for unusual types and keywords such as _huge void
200+
+** If not defined by this point then fallback to using Luas defaults
201+
+*/
202+
203+
+#ifndef LUA_HEAP_PTR_T
204+
+#define LUA_HEAP_PTR_T void
205+
+#endif
206+
+
207+
+#ifndef LUA_HEAP_SIZE_T
208+
+#define LUA_HEAP_SIZE_T size_t
209+
+#endif
210+
211+
#endif
212+

0 commit comments

Comments
 (0)