Skip to content

Commit 1c6f842

Browse files
committed
Added basic halloc boilerplate code to luaL_alloc function.
1 parent ecdcab0 commit 1c6f842

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

lua.pat

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- lua/lauxlib.c
22
+++ lua/lauxlib.c
3-
@@ -1046,7 +1046,10 @@ LUALIB_API const char *luaL_gsub (lua_State *L, const char *s,
3+
@@ -1046,14 +1046,32 @@ LUALIB_API const char *luaL_gsub (lua_State *L, const char *s,
44
}
55

66

@@ -11,8 +11,31 @@
1111
+ LUA_HEAP_SIZE_T nsize) {
1212
UNUSED(ud); UNUSED(osize);
1313
if (nsize == 0) {
14+
+#ifdef OW_HUGE_HEAP
15+
+ hfree(ptr);
16+
+#else
1417
free(ptr);
15-
18+
+#endif
19+
return NULL;
20+
- }
21+
- else
22+
+ } else {
23+
+#ifdef OW_HUGE_HEAP
24+
+ LUA_HEAP_PTR_T *new;
25+
+
26+
+ if (!(new = halloc(nsize, 1)))
27+
+ return NULL;
28+
+
29+
+ fmemcpy(new, old, osize < nsize ? osize : nsize);
30+
+ hfree(ptr);
31+
+ return new;
32+
+#else
33+
return realloc(ptr, nsize);
34+
+#endif
35+
+ }
36+
}
37+
38+
1639
--- lua/lauxlib.h
1740
+++ lua/lauxlib.h
1841
@@ -81,8 +81,9 @@ LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
@@ -121,7 +144,6 @@
121144
#else
122145
#define l_system(cmd) system(cmd) /* default definition */
123146
#endif
124-
125147
--- lua/luaconf.h
126148
+++ lua/luaconf.h
127149
@@ -95,7 +95,12 @@

0 commit comments

Comments
 (0)