简单地说,我遇到了一个问题,即在调用libnotify函数时我遇到了段错误。错误的代码:
int lua_libnotify_new(lua_State *L) {
const char *summary = luaL_checkstring(L, 1);
const char *body = lua_isstring(L, 2) ? lua_tostring(L, 2) : NULL;
const char *icon = lua_isstring(L, 3) ? lua_tostring(L, 3) : NULL;
NotifyNotification *notification = (NotifyNotification *)lua_newuserdata(L, sizeof(NotifyNotification));
/* Error is the below line */
notify_notification_update(notification, summary, body, icon);
return 1;
}
答案 0 :(得分:0)
经过一些修补,我意识到它应该是sizeof(NotifyNotification *)。解决。