]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use n_spaces in puts_tabular
authorTom Tromey <tom@tromey.com>
Thu, 8 Jan 2026 14:58:58 +0000 (07:58 -0700)
committerTom Tromey <tom@tromey.com>
Tue, 20 Jan 2026 17:02:42 +0000 (10:02 -0700)
This changes puts_tabular to use n_spaces rather than alloca.

Reviewed-By: Keith Seitz <keiths@redhat.com>
gdb/utils.c

index 97423e09d92d63ff9cf72cf5f09b667cedc416cc..46d100466bf1a2307e812b1d78077089ddb31e38 100644 (file)
@@ -1589,7 +1589,6 @@ void
 puts_tabular (const char *string, int width)
 {
   int spaces = 0;
-  char *spacebuf;
 
   gdb_assert (chars_per_line > 0);
   if (chars_per_line == UINT_MAX)
@@ -1608,12 +1607,7 @@ puts_tabular (const char *string, int width)
   if (chars_printed > 0)
     spaces = width - (chars_printed - 1) % width - 1;
 
-  spacebuf = (char *) alloca (spaces + 1);
-  spacebuf[spaces] = '\0';
-  while (spaces--)
-    spacebuf[spaces] = ' ';
-
-  gdb_puts (spacebuf);
+  gdb_puts (n_spaces (spaces));
   gdb_puts (string);
 }