Skip to content

Commit

Permalink
Simplified code and possible copy problem fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed Apr 10, 2009
1 parent e9b4d06 commit 1d498da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
2009-04-09 Ulrich Drepper <drepper@redhat.com>

* stdio-common/vfprintf.c (vfprintf): Slightly more compact code.
Simplified code and possible copy problem fixed.

* sysdeps/unix/sysv/linux/preadv.c: Avoid prototype for static
function if it is not defined. Add some necessary casts.
Expand Down
20 changes: 3 additions & 17 deletions stdio-common/vfprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1662,24 +1662,10 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
{
/* Extend the array of format specifiers. */
struct printf_spec *old = specs;
specs = extend_alloca (specs, nspecs_max, 2 * nspecs_max);

nspecs_max *= 2;
specs = alloca (nspecs_max * sizeof (struct printf_spec));

if (specs == &old[nspecs])
/* Stack grows up, OLD was the last thing allocated;
extend it. */
nspecs_max += nspecs_max / 2;
else
{
/* Copy the old array's elements to the new space. */
memcpy (specs, old, nspecs * sizeof (struct printf_spec));
if (old == &specs[nspecs])
/* Stack grows down, OLD was just below the new
SPECS. We can use that space when the new space
runs out. */
nspecs_max += nspecs_max / 2;
}
/* Copy the old array's elements to the new space. */
memmove (specs, old, nspecs * sizeof (struct printf_spec));
}

/* Parse the format specifier. */
Expand Down

0 comments on commit 1d498da

Please sign in to comment.