Enlightenment CVS committal Author : ningerso Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_callback.c Log Message: Use the stack for allocating a temp callback for registration. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_callback.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- ewl_callback.c 13 Jul 2006 00:20:29 -0000 1.21 +++ ewl_callback.c 24 Jul 2006 23:52:30 -0000 1.22 @@ -15,7 +15,6 @@ static unsigned int ewl_callback_hash(void *key); static int ewl_callback_compare(void *key1, void *key2); -static Ewl_Callback *ewl_callback_register(Ewl_Callback * cb); static void ewl_callback_unregister(Ewl_Callback * cb); static Ewl_Callback *ewl_callback_get(Ewl_Widget *w, unsigned int type, unsigned int idx); @@ -82,35 +81,6 @@ } /* - * ewl_callback_register - register a callback to check for duplicates - * @cb: the callback to register - * - * Returns a pointer to the callback that should be used instead of the passed - * @cb on success, NULL on failure. The returned callback may in fact be @cb, - * but this can not be counted on. The callback @cb will be freed if this is - * not the case. - */ -static Ewl_Callback * -ewl_callback_register(Ewl_Callback *cb) -{ - Ewl_Callback *found; - - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("cb", cb, NULL); - - found = ecore_hash_get(cb_registration, cb); - if (!found) { - found = cb; - found->id = ++callback_id; - ecore_hash_set(cb_registration, found, found); - } - - found->references++; - - DRETURN_PTR(found, DLEVEL_STABLE); -} - -/* * ewl_callback_unregister - unreference a callback and free if appropriate * @cb: the callback to unregister * @@ -304,19 +274,32 @@ if (type < EWL_CALLBACK_MAX) { - cb = NEW(Ewl_Callback, 1); + cb = alloca(sizeof(Ewl_Callback)); } else { - cb = NEW(Ewl_Callback_Custom, 1); + cb = alloca(sizeof(Ewl_Callback_Custom)); EWL_CALLBACK_CUSTOM(cb)->event_id = type; } cb->func = func; cb->user_data = user_data; - found = ewl_callback_register(cb); - if (cb != found) FREE(cb); + found = ecore_hash_get(cb_registration, cb); + if (!found) { + if (type < EWL_CALLBACK_MAX) { + found = NEW(Ewl_Callback, 1); + } + else { + found = NEW(Ewl_Callback_Custom, 1); + } + found->func = func; + found->user_data = user_data; + found->id = ++callback_id; + ecore_hash_set(cb_registration, found, found); + } + + found->references++; ret = ewl_callback_insert(w, type, found, pos); ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs