From 2684d78c89ad7cfd18346398691e6e03d263f6c6 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 11 Mar 2010 17:03:32 +0000 Subject: - Use an initializer macro to initialize fields in 'fake' FILE objects used by *sprintf(), etc. - Explicitly initialize _fl_mutex to PTHREAD_MUTEX_INITIALIZER for all FILE objects. This is currently a nop on FreeBSD, but is import for other platforms (or in the future) where PTHREAD_MUTEX_INITIALIZER is not simply zero. PR: threads/141198 Reported by: Jeremy Huddleston @ Apple MFC after: 2 weeks --- lib/libc/stdio/vasprintf.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lib/libc/stdio/vasprintf.c') diff --git a/lib/libc/stdio/vasprintf.c b/lib/libc/stdio/vasprintf.c index 0682b5b..0dcdac9 100644 --- a/lib/libc/stdio/vasprintf.c +++ b/lib/libc/stdio/vasprintf.c @@ -42,9 +42,8 @@ vasprintf(str, fmt, ap) __va_list ap; { int ret; - FILE f; + FILE f = FAKE_FILE; - f._file = -1; f._flags = __SWR | __SSTR | __SALC; f._bf._base = f._p = (unsigned char *)malloc(128); if (f._bf._base == NULL) { @@ -53,8 +52,6 @@ vasprintf(str, fmt, ap) return (-1); } f._bf._size = f._w = 127; /* Leave room for the NUL */ - f._orientation = 0; - memset(&f._mbstate, 0, sizeof(mbstate_t)); ret = __vfprintf(&f, fmt, ap); if (ret < 0) { free(f._bf._base); -- cgit v1.1 From 48496193ae9553467f32b177c73be5f1b8fd9fd1 Mon Sep 17 00:00:00 2001 From: obrien Date: Mon, 5 Apr 2010 22:09:29 +0000 Subject: I feel this wording of the history is more clear. ANSIfy vasprintf() while I'm here. --- lib/libc/stdio/vasprintf.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'lib/libc/stdio/vasprintf.c') diff --git a/lib/libc/stdio/vasprintf.c b/lib/libc/stdio/vasprintf.c index 0dcdac9..a1b600a 100644 --- a/lib/libc/stdio/vasprintf.c +++ b/lib/libc/stdio/vasprintf.c @@ -36,16 +36,13 @@ __FBSDID("$FreeBSD$"); #include "local.h" int -vasprintf(str, fmt, ap) - char **str; - const char *fmt; - __va_list ap; +vasprintf(char **str, const char *fmt, __va_list ap) { - int ret; FILE f = FAKE_FILE; + int ret; f._flags = __SWR | __SSTR | __SALC; - f._bf._base = f._p = (unsigned char *)malloc(128); + f._bf._base = f._p = malloc(128); if (f._bf._base == NULL) { *str = NULL; errno = ENOMEM; -- cgit v1.1