summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/m_database.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-04-24 13:13:31 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-04-24 13:13:31 +0000
commit0080cd035eaa00062b5f0f494be1e8862d8548b7 (patch)
treefabf8dda506c5637328f03770f676e152cfd64c7 /plugins/MirLua/src/m_database.cpp
parent79812b0325d58e7954d4aec16aa8dddfec9c5479 (diff)
MirLua: fixed CONTACTINFO metatable
git-svn-id: http://svn.miranda-ng.org/main/trunk@16760 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_database.cpp')
-rw-r--r--plugins/MirLua/src/m_database.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp
index a493970bfc..f81baf06b6 100644
--- a/plugins/MirLua/src/m_database.cpp
+++ b/plugins/MirLua/src/m_database.cpp
@@ -577,20 +577,14 @@ void MT<DBEVENTINFO>::Free(lua_State*, DBEVENTINFO **dbei)
void MT<CONTACTINFO>::Init(lua_State *L, CONTACTINFO **ci)
{
- MCONTACT hContact = 0;
- switch (lua_type(L, 1))
+ if (!lua_isinteger(L, 1))
{
- case LUA_TNUMBER:
- hContact = lua_tointeger(L, 1);
- break;
- case LUA_TLIGHTUSERDATA:
- hContact = (MCONTACT)lua_touserdata(L, 1);
- break;
- default:
const char *msg = lua_pushfstring(L, "hContact expected, got %s", luaL_typename(L, 1));
luaL_argerror(L, 1, msg);
}
+ MCONTACT hContact = luaL_checkinteger(L, 1);
+ (*ci) = (CONTACTINFO*)mir_calloc(sizeof(CONTACTINFO));
(*ci)->cbSize = sizeof(CONTACTINFO);
(*ci)->hContact = hContact;
}
@@ -681,6 +675,11 @@ int MT<CONTACTINFO>::Index(lua_State *L, CONTACTINFO *ci)
return 1;
}
+void MT<CONTACTINFO>::Free(lua_State *L, CONTACTINFO **ci)
+{
+ mir_free((*ci));
+}
+
/***********************************************/
LUAMOD_API int luaopen_m_database(lua_State *L)