[03/13] gdb: remove use of alloca from c-lang.c

Message ID ba50b57ba8d0003759cc5042adee6e74a0d60a23.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 c-lang.c and replace it with
gdb::byte_vector.

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

Patch

diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 6535ab93498..faac5d47179 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -430,11 +430,9 @@  static void
 emit_numeric_character (struct type *type, unsigned long value,
 			struct obstack *output)
 {
-  gdb_byte *buffer;
-
-  buffer = (gdb_byte *) alloca (type->length ());
-  pack_long (buffer, type, value);
-  obstack_grow (output, buffer, type->length ());
+  gdb::byte_vector buffer (type->length ());
+  pack_long (buffer.data (), type, value);
+  obstack_grow (output, buffer.data (), type->length ());
 }
 
 /* Convert an octal escape sequence.  TYPE is the target character