varobj_item *saved_item;
};
-struct cpstack
-{
- char *name;
- struct cpstack *next;
-};
-
/* A list of varobjs */
struct vlist
/* Helper functions for the above subcommands. */
-static int delete_variable (struct cpstack **, struct varobj *, int);
+static int delete_variable (struct varobj *, int);
-static void delete_variable_1 (struct cpstack **, int *,
- struct varobj *, int, int);
+static void delete_variable_1 (int *, struct varobj *, int, int);
static int install_variable (struct varobj *);
static enum varobj_display_formats variable_default_display (struct varobj *);
-static void cppush (struct cpstack **pstack, char *name);
-
-static char *cppop (struct cpstack **pstack);
-
static int update_type_if_necessary (struct varobj *var,
struct value *new_value);
return name_of_variable (var);
}
-/* Deletes a varobj and all its children if only_children == 0,
- otherwise deletes only the children. If DELLIST is non-NULL, it is
- assigned a malloc'ed list of all the (malloc'ed) names of the variables
- that have been deleted (NULL terminated). Returns the number of deleted
- variables. */
+/* See varobj.h. */
int
-varobj_delete (struct varobj *var, char ***dellist, int only_children)
+varobj_delete (struct varobj *var, int only_children)
{
- int delcount;
- int mycount;
- struct cpstack *result = NULL;
- char **cp;
-
- /* Initialize a stack for temporary results. */
- cppush (&result, NULL);
-
- if (only_children)
- /* Delete only the variable children. */
- delcount = delete_variable (&result, var, 1 /* only the children */ );
- else
- /* Delete the variable and all its children. */
- delcount = delete_variable (&result, var, 0 /* parent+children */ );
-
- /* We may have been asked to return a list of what has been deleted. */
- if (dellist != NULL)
- {
- *dellist = XNEWVEC (char *, delcount + 1);
-
- cp = *dellist;
- mycount = delcount;
- *cp = cppop (&result);
- while ((*cp != NULL) && (mycount > 0))
- {
- mycount--;
- cp++;
- *cp = cppop (&result);
- }
-
- if (mycount || (*cp != NULL))
- warning (_("varobj_delete: assertion failed - mycount(=%d) <> 0"),
- mycount);
- }
-
- return delcount;
+ return delete_variable (var, only_children);
}
#if HAVE_PYTHON
*cchanged = 1;
for (j = i; j < VEC_length (varobj_p, var->children); ++j)
- varobj_delete (VEC_index (varobj_p, var->children, j), NULL, 0);
+ varobj_delete (VEC_index (varobj_p, var->children, j), 0);
VEC_truncate (varobj_p, var->children, i);
}
var->type = new_type;
/* This information may be not valid for a new type. */
- varobj_delete (var, NULL, 1);
+ varobj_delete (var, 1);
VEC_free (varobj_p, var->children);
var->num_children = -1;
return 1;
Py_XDECREF (constructor);
/* If there are any children now, wipe them. */
- varobj_delete (var, NULL, 1 /* children only */);
+ varobj_delete (var, 1 /* children only */);
var->num_children = -1;
do_cleanups (back_to);
{
/* The children are no longer valid; delete them now.
Report the fact that its type changed as well. */
- varobj_delete (v, NULL, 1 /* only_children */);
+ varobj_delete (v, 1 /* only_children */);
v->num_children = -1;
v->to = -1;
v->from = -1;
*/
static int
-delete_variable (struct cpstack **resultp, struct varobj *var,
- int only_children_p)
+delete_variable (struct varobj *var, int only_children_p)
{
int delcount = 0;
- delete_variable_1 (resultp, &delcount, var,
- only_children_p, 1 /* remove_from_parent_p */ );
+ delete_variable_1 (&delcount, var, only_children_p,
+ 1 /* remove_from_parent_p */ );
return delcount;
}
and the parent is not removed we dump core. It must be always
initially called with remove_from_parent_p set. */
static void
-delete_variable_1 (struct cpstack **resultp, int *delcountp,
- struct varobj *var, int only_children_p,
+delete_variable_1 (int *delcountp, struct varobj *var, int only_children_p,
int remove_from_parent_p)
{
int i;
continue;
if (!remove_from_parent_p)
child->parent = NULL;
- delete_variable_1 (resultp, delcountp, child, 0, only_children_p);
+ delete_variable_1 (delcountp, child, 0, only_children_p);
}
VEC_free (varobj_p, var->children);
yet been installed, don't report it, it belongs to the caller... */
if (var->obj_name != NULL)
{
- cppush (resultp, xstrdup (var->obj_name));
*delcountp = *delcountp + 1;
}
return FORMAT_NATURAL;
}
-/* FIXME: The following should be generic for any pointer. */
-static void
-cppush (struct cpstack **pstack, char *name)
-{
- struct cpstack *s;
-
- s = XNEW (struct cpstack);
- s->name = name;
- s->next = *pstack;
- *pstack = s;
-}
-
-/* FIXME: The following should be generic for any pointer. */
-static char *
-cppop (struct cpstack **pstack)
-{
- struct cpstack *s;
- char *v;
-
- if ((*pstack)->name == NULL && (*pstack)->next == NULL)
- return NULL;
-
- s = *pstack;
- v = s->name;
- *pstack = (*pstack)->next;
- xfree (s);
-
- return v;
-}
-\f
/*
* Language-dependencies
*/
var->root->exp = tmp_var->root->exp;
tmp_var->root->exp = tmp_exp;
- varobj_delete (tmp_var, NULL, 0);
+ varobj_delete (tmp_var, 0);
*type_changed = 0;
}
else
tmp_var->obj_name = xstrdup (var->obj_name);
tmp_var->from = var->from;
tmp_var->to = var->to;
- varobj_delete (var, NULL, 0);
+ varobj_delete (var, 0);
install_variable (tmp_var);
*var_handle = tmp_var;
/* The type has mutated, so the children are no longer valid.
Just delete them, and tell our caller that the type has
changed. */
- varobj_delete (var, NULL, 1 /* only_children */);
+ varobj_delete (var, 1 /* only_children */);
var->num_children = -1;
var->to = -1;
var->from = -1;
if (tmp_var != NULL)
{
tmp_var->obj_name = xstrdup (var->obj_name);
- varobj_delete (var, NULL, 0);
+ varobj_delete (var, 0);
install_variable (tmp_var);
}
else