1414#include " lua.h"
1515
1616
17+ /* Note: luaM_error must remain a macro due to lua_State forward declaration */
1718#define luaM_error (L ) (L)->doThrow (LUA_ERRMEM)
1819
1920
@@ -54,8 +55,6 @@ inline constexpr int luaM_limitN(int n) noexcept {
5455#define luaM_reallocvchar (L,b,on,n ) \
5556 cast_charp (luaM_saferealloc_(L, (b), (on)*sizeof(char ), (n)*sizeof(char )))
5657
57- #define luaM_freemem (L, b, s ) luaM_free_(L, (b), (s))
58-
5958/* Forward declarations of underlying memory functions */
6059LUAI_FUNC l_noret luaM_toobig (lua_State *L);
6160LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
@@ -70,6 +69,15 @@ LUAI_FUNC void *luaM_shrinkvector_ (lua_State *L, void *block, int *nelem,
7069 int final_n, unsigned size_elem);
7170LUAI_FUNC void *luaM_malloc_ (lua_State *L, size_t size, int tag);
7271
72+ /* Phase 128: Convert luaM_freemem and luaM_newobject macros to inline functions */
73+ inline void luaM_freemem (lua_State* L, void * b, size_t s) {
74+ luaM_free_ (L, b, s);
75+ }
76+
77+ inline void * luaM_newobject (lua_State* L, int tag, size_t s) {
78+ return luaM_malloc_ (L, s, tag);
79+ }
80+
7381/*
7482** Template-based memory management functions for type safety.
7583** These replace the old macros with proper C++ templates.
@@ -106,8 +114,6 @@ inline T* luaM_newvectorchecked(lua_State* L, size_t n) {
106114 return luaM_newvector<T>(L, n);
107115}
108116
109- #define luaM_newobject (L,tag,s ) luaM_malloc_(L, (s), tag)
110-
111117/* Allocate a block of size bytes (char array) */
112118inline char * luaM_newblock (lua_State* L, size_t size) {
113119 return luaM_newvector<char >(L, size);
0 commit comments