Make global_symbol_searcher::filenames private

This patch renames global_symbol_searcher::filenames and makes it
private, adding a new method to append a filename to the vector.  This
also cleans up memory management here, removing an alloca from rbreak,
and removing a somewhat ugly SCOPE_EXIT from the Python code, in favor
of having global_symbol_searcher manage the memory itself.

Regression tested on x86-64 Fedora 38.
This commit is contained in:
Tom Tromey
2024-05-24 12:31:45 -06:00
parent 58a628530e
commit c4c093a31f
3 changed files with 25 additions and 34 deletions

View File

@@ -804,10 +804,6 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
}
global_symbol_searcher spec (SEARCH_FUNCTION_DOMAIN, regex);
SCOPE_EXIT {
for (const char *elem : spec.filenames)
xfree ((void *) elem);
};
/* The "symtabs" keyword is any Python iterable object that returns
a gdb.Symtab on each iteration. If specified, iterate through
@@ -852,10 +848,7 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
if (filename == NULL)
return NULL;
/* Make sure there is a definite place to store the value of
filename before it is released. */
spec.filenames.push_back (nullptr);
spec.filenames.back () = filename.release ();
spec.add_filename (std::move (filename));
}
}