[07/13] gdb: remove use of alloca from findvar.c

Message ID e49e4905e3c8645ed6a08292b45b1f4ffc678d04.1677533215.git.aburgess@redhat.com
State New
Headers
Series Remove a bunch of alloca uses |

Commit Message

Andrew Burgess Feb. 27, 2023, 9:29 p.m. UTC
  Remove the use of alloca from findvar.c and replace it with
gdb::byte_vector.

There should be no user visible changes after this commit.
---
 gdb/findvar.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gdb/findvar.c b/gdb/findvar.c
index 60b5ca3faf3..2c5ee11a2c7 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -951,11 +951,11 @@  address_from_register (int regnum, frame_info_ptr frame)
      pointer types.  Avoid constructing a value object in those cases.  */
   if (gdbarch_convert_register_p (gdbarch, regnum, type))
     {
-      gdb_byte *buf = (gdb_byte *) alloca (type->length ());
+      gdb::byte_vector buf (type->length ());
       int optim, unavail, ok;
 
       ok = gdbarch_register_to_value (gdbarch, frame, regnum, type,
-				      buf, &optim, &unavail);
+				      buf.data (), &optim, &unavail);
       if (!ok)
 	{
 	  /* This function is used while computing a location expression.
@@ -965,7 +965,7 @@  address_from_register (int regnum, frame_info_ptr frame)
 	  error_value_optimized_out ();
 	}
 
-      return unpack_long (type, buf);
+      return unpack_long (type, buf.data ());
     }
 
   value = gdbarch_value_from_register (gdbarch, type, regnum, null_frame_id);