gdb: remove last alloca call from printcmd.c
This commit removes the last alloca call from printcmd.c. This is
similar to the patches I originally posted here:
https://inbox.sourceware.org/gdb-patches/cover.
1677533215.git.aburgess@redhat.com/
However, this change was not included in that original series.
The original series received push back because it was thought that
replacing alloca with a C++ container type would introduce unnecessary
malloc/free overhead.
However, in this case we are building a string, and (at least for
GCC), the std::string type has a small string optimisation, where
small strings are stored on the stack.
And in this case we are building what will usually be a very small
string, we're just constructing a printf format specifier for a hex
value, so it'll be something like '%#x' -- though it could also have a
width in there too -- but still, it should normally fit within GCCs
small string buffer.
So, in this commit, I propose replacing the use of alloca with a
std::string. This shouldn't result (normally) in any additional
malloc or free calls, so should be similar in performance to the
original approach.
There should be no user visible differences after this commit.