[09/13] gdb: remove use of alloca from mem-break.c
Commit Message
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(-)
@@ -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);
}