From 9d104ff0b910721c0daaf68c54a17d63e89e574b Mon Sep 17 00:00:00 2001 From: Rui Guo Date: Mon, 15 Jun 2009 21:54:34 +0800 Subject: [PATCH] No longer check for duplicate hook. --- src/lua.c | 18 ++---------------- src/script.c | 13 ------------- src/script.h | 1 - 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/src/lua.c b/src/lua.c index d09e280..e64ee98 100644 --- a/src/lua.c +++ b/src/lua.c @@ -341,7 +341,7 @@ callback_unhook(lua_State *L) } else { - LuaFreeHandler(L, &(*ppl)->handler); + LuaFreeHandler(L, (lua_handler *)&(*ppl)->handler); unregister_listener(*ppl); *ppl = 0; lua_pushboolean(L, 1); @@ -1128,12 +1128,6 @@ LuaCheckHandler(lua_State *L, int idx, int ref) return LuaAllocHandler(NULL, key); } -int -LuaHdlrComp(void *h1, void *h2) -{ - return (lua_handler)h1 - (lua_handler)h2; -} - /* }}} **/ static int @@ -1231,14 +1225,7 @@ LuaRegEvent(lua_State *L) l->priv = priv; l->bd = &lua_binding; l->handler = (void *)lh; - if (register_listener(sev, l)) - { - free(l); - if (lh->type == LUA_HANDLER_TYPE_N) - return luaL_error(L, "Handler %s has already been registered", lh->u.name); - else - return luaL_error(L, "Handler has already been registered"); - } + register_listener(sev, l); /* Return the ticket for un-register */ push_callback(L, &l); } @@ -1267,7 +1254,6 @@ struct binding lua_binding = LuaCall, LuaSource, LuaDispatch, - LuaHdlrComp, 0, /*b_next*/ &LuaFuncs }; diff --git a/src/script.c b/src/script.c index f567115..9626228 100644 --- a/src/script.c +++ b/src/script.c @@ -247,22 +247,9 @@ register_listener(struct script_event *ev, struct listener *l) while(iter->chain && priv >= iter->chain->priv) { iter = iter->chain; - /* return if duplicate found*/ - if (iter->bd == l->bd - && !iter->bd->bd_hdlrcmp(iter->handler, l->handler)) - return 1; } p = iter; - while(iter->chain) - { - iter = iter->chain; - /* return if duplicate found*/ - if (iter->bd == l->bd - && !iter->bd->bd_hdlrcmp(iter->handler, l->handler)) - return 1; - } - l->chain = p->chain; l->prev = p; if (p->chain) diff --git a/src/script.h b/src/script.h index 6870d31..422c02b 100644 --- a/src/script.h +++ b/src/script.h @@ -44,7 +44,6 @@ struct binding * a non-zero value will stop further * notification to the rest of the chain.*/ int (*bd_dispatch) __P((void *handler, const char *params, va_list va)); - int (*bd_hdlrcmp) __P((void * h1, void *h2)); struct binding *b_next; struct ScriptFuncs *fns; -- 2.11.4.GIT