Browse Source

Avoid using lightuserdata in internal wrapper code for the math module.

Alex Szpakowski 6 years ago
parent
commit
32f381576e
2 changed files with 3 additions and 3 deletions
  1. 1 1
      src/modules/math/wrap_Math.cpp
  2. 2 2
      src/modules/math/wrap_Math.lua

+ 1 - 1
src/modules/math/wrap_Math.cpp

@@ -500,7 +500,7 @@ extern "C" int luaopen_love_math(lua_State *L)
 	// Execute wrap_Math.lua, sending the math table and ffifuncs pointer as args.
 	// Execute wrap_Math.lua, sending the math table and ffifuncs pointer as args.
 	luaL_loadbuffer(L, math_lua, sizeof(math_lua), "wrap_Math.lua");
 	luaL_loadbuffer(L, math_lua, sizeof(math_lua), "wrap_Math.lua");
 	lua_pushvalue(L, -2);
 	lua_pushvalue(L, -2);
-	lua_pushlightuserdata(L, &ffifuncs);
+	luax_pushpointerasstring(L, &ffifuncs);
 	lua_call(L, 2, 0);
 	lua_call(L, 2, 0);
 
 
 	return n;
 	return n;

+ 2 - 2
src/modules/math/wrap_Math.lua

@@ -22,7 +22,7 @@ misrepresented as being the original software.
 3. This notice may not be removed or altered from any source distribution.
 3. This notice may not be removed or altered from any source distribution.
 --]]
 --]]
 
 
-local love_math, ffifuncspointer = ...
+local love_math, ffifuncspointer_str = ...
 
 
 local type, tonumber, error = type, tonumber, error
 local type, tonumber, error = type, tonumber, error
 local floor = math.floor
 local floor = math.floor
@@ -103,7 +103,7 @@ typedef struct FFI_Math
 } FFI_Math;
 } FFI_Math;
 ]])
 ]])
 
 
-local ffifuncs = ffi.cast("FFI_Math *", ffifuncspointer)
+local ffifuncs = ffi.cast("FFI_Math **", ffifuncspointer_str)[0]
 
 
 
 
 -- Overwrite some regular love.math functions with FFI implementations.
 -- Overwrite some regular love.math functions with FFI implementations.