Exemple #1
0
/**
 *Destroys the selector list.
 *@param a_this the current instance of #CRSelector.
 */
void
cr_selector_destroy (CRSelector * a_this)
{
        CRSelector *cur = NULL;

        g_return_if_fail (a_this);

        /*
         *go and get the list tail. In the same time, free
         *all the simple selectors contained in the list.
         */
        for (cur = a_this; cur && cur->next; cur = cur->next) {
                if (cur->simple_sel) {
                        cr_simple_sel_destroy (cur->simple_sel);
                        cur->simple_sel = NULL;
                }
        }

        if (cur) {
                if (cur->simple_sel) {
                        cr_simple_sel_destroy (cur->simple_sel);
                        cur->simple_sel = NULL;
                }
        }

        /*in case the list has only one element */
        if (cur && !cur->prev) {
                g_free (cur);
                return;
        }

        /*walk backward the list and free each "next element" */
        for (cur = cur->prev; cur && cur->prev; cur = cur->prev) {
                if (cur->next) {
                        g_free (cur->next);
                        cur->next = NULL;
                }
        }

        if (!cur)
                return;

        if (cur->next) {
                g_free (cur->next);
                cur->next = NULL;
        }

        g_free (cur);
}
Exemple #2
0
/**
 * cr_simple_sel_destroy:
 *
 *@a_this: the this pointer of the current instance of #CRSimpleSel.
 *
 *The destructor of the current instance of
 *#CRSimpleSel. Recursively calls the destructor of #CRSimpleSel->next
 */
void
cr_simple_sel_destroy (CRSimpleSel * const a_this)
{
        g_return_if_fail (a_this);

        if (a_this->name) {
                cr_string_destroy (a_this->name);
                a_this->name = NULL;
        }

        if (a_this->add_sel) {
                cr_additional_sel_destroy (a_this->add_sel);
                a_this->add_sel = NULL;
        }

        if (a_this->next) {
                cr_simple_sel_destroy (a_this->next);
                a_this->next = NULL;
        }

        g_free (a_this);
}