summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libc/stdio/vfprintf.c15
-rw-r--r--lib/libc/stdio/vfwprintf.c15
2 files changed, 18 insertions, 12 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 3285c37..cd147b8 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -1321,7 +1321,8 @@ __find_arguments (const char *fmt0, va_list ap, union arg **argtable)
tablesize = STATIC_ARG_TBL_SIZE;
tablemax = 0;
nextarg = 1;
- memset (typetable, T_UNUSED, STATIC_ARG_TBL_SIZE);
+ for (n = 0; n < STATIC_ARG_TBL_SIZE; n++)
+ typetable[n] = T_UNUSED;
/*
* Scan the format for conversions (`%' character).
@@ -1590,19 +1591,21 @@ __grow_type_table (int nextarg, enum typeid **typetable, int *tablesize)
enum typeid *const oldtable = *typetable;
const int oldsize = *tablesize;
enum typeid *newtable;
- int newsize = oldsize * 2;
+ int n, newsize = oldsize * 2;
if (newsize < nextarg + 1)
newsize = nextarg + 1;
if (oldsize == STATIC_ARG_TBL_SIZE) {
- if ((newtable = malloc(newsize)) == NULL)
+ if ((newtable = malloc(newsize * sizeof(enum typeid))) == NULL)
abort(); /* XXX handle better */
- bcopy(oldtable, newtable, oldsize);
+ bcopy(oldtable, newtable, oldsize * sizeof(enum typeid));
} else {
- if ((newtable = reallocf(oldtable, newsize)) == NULL)
+ newtable = reallocf(oldtable, newsize * sizeof(enum typeid));
+ if (newtable == NULL)
abort(); /* XXX handle better */
}
- memset(&newtable[oldsize], T_UNUSED, newsize - oldsize);
+ for (n = oldsize; n < newsize; n++)
+ newtable[n] = T_UNUSED;
*typetable = newtable;
*tablesize = newsize;
diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c
index 9a34ff0..afecc97 100644
--- a/lib/libc/stdio/vfwprintf.c
+++ b/lib/libc/stdio/vfwprintf.c
@@ -1317,7 +1317,8 @@ __find_arguments (const wchar_t *fmt0, va_list ap, union arg **argtable)
tablesize = STATIC_ARG_TBL_SIZE;
tablemax = 0;
nextarg = 1;
- memset (typetable, T_UNUSED, STATIC_ARG_TBL_SIZE);
+ for (n = 0; n < STATIC_ARG_TBL_SIZE; n++)
+ typetable[n] = T_UNUSED;
/*
* Scan the format for conversions (`%' character).
@@ -1586,19 +1587,21 @@ __grow_type_table (int nextarg, enum typeid **typetable, int *tablesize)
enum typeid *const oldtable = *typetable;
const int oldsize = *tablesize;
enum typeid *newtable;
- int newsize = oldsize * 2;
+ int n, newsize = oldsize * 2;
if (newsize < nextarg + 1)
newsize = nextarg + 1;
if (oldsize == STATIC_ARG_TBL_SIZE) {
- if ((newtable = malloc(newsize)) == NULL)
+ if ((newtable = malloc(newsize * sizeof(enum typeid))) == NULL)
abort(); /* XXX handle better */
- bcopy(oldtable, newtable, oldsize);
+ bcopy(oldtable, newtable, oldsize * sizeof(enum typeid));
} else {
- if ((newtable = reallocf(oldtable, newsize)) == NULL)
+ newtable = reallocf(oldtable, newsize * sizeof(enum typeid));
+ if (newtable == NULL)
abort(); /* XXX handle better */
}
- memset(&newtable[oldsize], T_UNUSED, newsize - oldsize);
+ for (n = oldsize; n < newsize; n++)
+ newtable[n] = T_UNUSED;
*typetable = newtable;
*tablesize = newsize;
OpenPOWER on IntegriCloud