- 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 = xmalloc ((delcount + 1) * sizeof (char *));
-
- 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;