This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH RFA] mi/mi-main.c: Don't use variable-length array extension
- To: gdb-patches at sources dot redhat dot com
- Subject: [PATCH RFA] mi/mi-main.c: Don't use variable-length array extension
- From: Kevin Buettner <kevinb at cygnus dot com>
- Date: Sun, 8 Jul 2001 23:28:33 -0700
These are probably obvious fixes, but I used alloca() which is
sometimes considered objectionable, so I decided to ask for approval.
I'm willing to rework the patch to use xmalloc(), make_cleanup(), etc,
but it will be messier.
* mi-main.c (register_changed_p, get_register): Use alloca()
to allocate space previously allocated via gcc's
variable-length array extension.
Index: mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.19
diff -u -p -r1.19 mi-main.c
--- mi-main.c 2001/06/25 21:05:11 1.19
+++ mi-main.c 2001/07/09 06:17:35
@@ -378,7 +378,7 @@ mi_cmd_data_list_changed_registers (char
static int
register_changed_p (int regnum)
{
- char raw_buffer[MAX_REGISTER_RAW_SIZE];
+ char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
if (read_relative_register_raw_bytes (regnum, raw_buffer))
return -1;
@@ -483,8 +483,8 @@ mi_cmd_data_list_register_values (char *
static int
get_register (int regnum, int format)
{
- char raw_buffer[MAX_REGISTER_RAW_SIZE];
- char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
+ char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
+ char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
int optim;
static struct ui_stream *stb = NULL;