[09/13] gdb: remove use of alloca from mem-break.c

Message ID d7b8a22f54e48341354f56cdd8729dab9efcb5eb.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
  Replace the use of alloca with gdb::byte_vector in mem-break.c.

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

Patch

diff --git a/gdb/mem-break.c b/gdb/mem-break.c
index abff4b47081..81059b37335 100644
--- a/gdb/mem-break.c
+++ b/gdb/mem-break.c
@@ -41,7 +41,6 @@  default_memory_insert_breakpoint (struct gdbarch *gdbarch,
 {
   CORE_ADDR addr = bp_tgt->placed_address;
   const unsigned char *bp;
-  gdb_byte *readbuf;
   int bplen;
   int val;
 
@@ -50,8 +49,8 @@  default_memory_insert_breakpoint (struct gdbarch *gdbarch,
 
   /* Save the memory contents in the shadow_contents buffer and then
      write the breakpoint instruction.  */
-  readbuf = (gdb_byte *) alloca (bplen);
-  val = target_read_memory (addr, readbuf, bplen);
+  gdb::byte_vector readbuf (bplen);
+  val = target_read_memory (addr, readbuf.data (), bplen);
   if (val == 0)
     {
       /* These must be set together, either before or after the shadow
@@ -63,7 +62,7 @@  default_memory_insert_breakpoint (struct gdbarch *gdbarch,
 	 conditions/commands on the target side for some types of
 	 breakpoints, such as target remote.  */
       bp_tgt->shadow_len = bplen;
-      memcpy (bp_tgt->shadow_contents, readbuf, bplen);
+      memcpy (bp_tgt->shadow_contents, readbuf.data (), bplen);
 
       val = target_write_raw_memory (addr, bp, bplen);
     }