All pastes #23104 Raw Edit

Untitled

public text v1 · immutable
#23104 ·published 2005-09-16 15:49 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)
        {
                w->callbacks[t].len = 0;
                w->callbacks[t].list[0] = NULL;
                FREE(w->callbacks[t].list);

                DRETURN(DLEVEL_STABLE);
        }

printf("%d %p\n", pos, w->callbacks[t].list[pos]);
{
int i;
for (i = 0; i < EWL_CALLBACK_LEN(w, t); i++)
        printf("%p ", w->callbacks[t].list[i]);
printf("\n");
}

        /* 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);

{
int i;
for (i = 0; i < EWL_CALLBACK_LEN(w, t); i++)
        printf("%p ", w->callbacks[t].list[i]);
printf("\n");
}
printf("---\n");

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}