All pastes #23103 Raw Edit

Stuff

public text v1 · immutable
#23103 ·published 2005-09-16 15:19 UTC
rendered paste body
static void                               
ewl_callback_rm(Ewl_Widget *w, Ewl_Callback_Type t, unsigned int pos)
{       
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);

        /* deal with the direct case first */
        if (w->callbacks[t].mask & EWL_CALLBACK_TYPE_DIRECT)
        {       
                ewl_callback_unregister((Ewl_Callback *)w->callbacks[t].list);

                w->callbacks[t].len = 0;
                w->callbacks[t].list = NULL;
                EWL_CALLBACK_SET_NODIRECT(w, t);
        
                DRETURN(DLEVEL_STABLE);
        }

        ewl_callback_unregister(w->callbacks[t].list[pos]);

        /* if this will empty the list (we've already handled direct) */
        if ((EWL_CALLBACK_LEN(w, t) - 1) == 0)
        {       
                FREE(w->callbacks[t].list);
                w->callbacks[t].len = 0;

                DRETURN(DLEVEL_STABLE);
        }
        
        /* not the last position */
        if (pos != (EWL_CALLBACK_LEN(w, t) - 1))
        {
                memmove(w->callbacks[t].list + pos,
                        w->callbacks[t].list + (pos + 1),
                        (w->callbacks[t].len - pos - 1) * sizeof(void *));
        }

        w->callbacks[t].len -= 1;
        w->callbacks[t].list[EWL_CALLBACK_LEN(w, t)] = NULL;
        w->callbacks[t].list = realloc(w->callbacks[t].list,
                                        w->callbacks[t].len);

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}