lua-users home
lua-l archive

issue following array example in pil chapter 28.2

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,
I was going over pil's chapter 28. After creating the array library
described in
28.1 I moved ahead and set a metatable for all the new userdatums of type array
so we avoid processing things that are not arrays.
The first thing to do is create the metatable within luaopen_array so the
metatable exists.
When adding that function call:
luaL_newmetatable(L, "LuaBook.array"); // in luaopen_array()
I get an error from malloc because it is trying to free memory that has
not been allocated:
lua(73040) malloc: *** error for object 0x10e922380: pointer being
freed was not allocated
I tried to dynamically allocate the second parameter of
luaL_newmetatable but the
problem persists.
I am using lua 5.1.4 under osx.
Any help would be appreciated,
-drd

AltStyle によって変換されたページ (->オリジナル) /