summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2004-04-22 11:35:12 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2004-04-22 11:35:12 +0000
commitccc8c6c31f14d4167a8eab0a374d2c1ba9147af5 (patch)
treeb40d4b9124f86cade2e9682cc1d4306aed4ee47c
parentfe9892eabd817e794bfcc88098b2f8081ac7a924 (diff)
Notes
-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 3285c374ca93..cd147b85335b 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 9a34ff069e98..afecc971f9a0 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;