/* Delete a parent anchor and all its children. If a hyperdoc object ** is found hanging off the parent anchor then this is returned */ PRIVATE void * delete_family (HTAnchor * me) { HTParentAnchor * parent = NULL; if (!me) { HTTRACE(ANCH_TRACE, "AnchorDelete No anchor found\n"); return NULL; } parent = me->parent; HTTRACE(ANCH_TRACE, "AnchorDelete Remove parent %p and children\n" _ parent); /* Delete children */ if (parent->children) { int cnt = 0; for (; cnt<CHILD_HASH_SIZE; cnt++) { HTList * kids = parent->children[cnt]; if (kids) { HTChildAnchor * child; while ((child=(HTChildAnchor*)HTList_removeLastObject(kids))) { HT_FREE(child->tag); if (child->links) { HTList * cur = child->links; HTLink * pres; while ((pres = (HTLink *) HTList_nextObject(cur))) HTLink_delete(pres); HTList_delete(child->links); } HT_FREE(child); } HTList_delete(kids); parent->children[cnt] = NULL; } } } return delete_parent(parent); }
void debug_tree_replace_list (DebugTree *tree, const GList *expressions) { GtkTreeModel* model = gtk_tree_view_get_model (GTK_TREE_VIEW(tree->view)); GtkTreeIter iter; gboolean valid; GList *list = g_list_copy ((GList *)expressions); /* Keep in the tree only the variable in the list */ valid = gtk_tree_model_get_iter_first (model, &iter); while (valid) { GList *find = NULL; gchar *exp; DmaVariableData *node; gtk_tree_model_get (model, &iter, VARIABLE_COLUMN, &exp, DTREE_ENTRY_COLUMN, &node, -1); if ((node->deleted == FALSE) && (node->exited == FALSE) && (exp != NULL)) { find = g_list_find_custom (list, exp, (GCompareFunc)strcmp); } if (find) { /* Keep variable in tree, remove in add list */ list = g_list_delete_link (list, find); valid = gtk_tree_model_iter_next (model, &iter); } else { /* Remove variable from the tree */ delete_parent(model, NULL, &iter, tree->debugger); valid = gtk_tree_store_remove (GTK_TREE_STORE (model), &iter); } } /* Create new variable */ while (list) { IAnjutaDebuggerVariableObject var = {NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE, -1}; var.expression = (gchar *)(list->data); debug_tree_add_watch (tree, &var, TRUE); list = g_list_delete_link (list, list); } }
PUBLIC BOOL HTAnchor_delete (HTParentAnchor * me) { /* Don't delete if document is loaded */ if (!me || me->document) { HTTRACE(ANCH_TRACE, "Anchor...... Not deleted\n"); return NO; } /* Recursively try to delete target anchors */ delete_links ((HTAnchor *) me); if (!HTList_isEmpty(me->sources)) { /* There are still incoming links */ /* ** Delete all outgoing links from children, if any */ if (me->children) { int cnt = 0; for (; cnt<CHILD_HASH_SIZE; cnt++) { HTList * kids = me->children[cnt]; if (kids) { HTChildAnchor * child; while ((child = (HTChildAnchor *) HTList_nextObject(kids))) delete_links((HTAnchor *) child); return NO; /* Parent not deleted */ } } } /* ** No more incoming links : kill everything ** First, recursively delete children */ if (me->children) { int cnt = 0; for (; cnt<CHILD_HASH_SIZE; cnt++) { HTList * kids = me->children[cnt]; if (kids) { HTChildAnchor * child; while ((child=(HTChildAnchor *) HTList_removeLastObject(kids))) delete_links((HTAnchor *) child); HT_FREE(child->tag); HT_FREE(child); } } } } /* 2001/03/06: Bug fix by Serge Adda <*****@*****.**> HTAnchor_delete wasn't removing the reference to the deleted anchor. This caused a bug whenever requesting another anchor for the same URL. */ if (adult_table) { int hash; const char *p; HTList * adults; HTList * grownups; HTList * last; HTParentAnchor * foundAnchor; /* Select list from hash table */ for(p=me->address, hash=0; *p; p++) hash = (int) ((hash * 3 + (*(unsigned char*)p)) % PARENT_HASH_SIZE); adults = adult_table[hash]; /* Search list for anchor */ grownups = adults; last = grownups; while ((foundAnchor = (HTParentAnchor *) HTList_nextObject(grownups))){ if (!strcmp(foundAnchor->address, me->address)) { HTList_quickRemoveElement (grownups, last); break; } last = grownups; } } /* Now kill myself */ delete_parent(me); return YES; /* Parent deleted */ #if 0 if (! HTList_isEmpty (me->sources)) { /* There are still incoming links */ /* Delete all outgoing links from children, if any */ HTList *kids = me->children; while ((child = (HTChildAnchor *) HTList_nextObject (kids))) delete_links ((HTAnchor *) child); return NO; /* Parent not deleted */ } /* No more incoming links : kill everything */ /* First, recursively delete children */ while ((child = (HTChildAnchor *) HTList_removeLastObject (me->children))) { delete_links ((HTAnchor *) child); HT_FREE(child->tag); HT_FREE(child); } #endif }