gvplugin_list: remove dynamic allocations
This MR refactors some code using strdup
to instead manage a pointer+extent pair into the original string it wants to later reference. By avoiding heap allocation, we remove some failure paths (though these were unchecked anyway), reduce locking/contention, reduce memory pressure, and make this code more amenable to inter-procedural compiler optimizations.
This is one instance of an optimization we could likely do many times over. There are numerous locations where Graphviz unnecessarily strdup
s a substring that it thereafter never mutates and then free
s locally. None of these seem to be on hot paths, but this kind of optimization is a win on multiple axes so there seems little reason not to pursue it.
Edited by Matthew Fernandez