From 6aed4288eba64f8265b98d34fdfd0bc0cd76151d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Goddard=20Rosa?= Date: Sat, 30 Jan 2010 22:39:00 -0200 Subject: [PATCH] stdio: simplify asprintf() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ... by removing unneeded NULL check, as free() already does it. By the way, we don't need to set a stack variable back to NULL. Signed-off-by: André Goddard Rosa Change-Id: Id1f72e872f73366dddcea4abc75885a3d9a318c6 --- libc/stdio/asprintf.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libc/stdio/asprintf.c b/libc/stdio/asprintf.c index 73791407e..1257c7f24 100644 --- a/libc/stdio/asprintf.c +++ b/libc/stdio/asprintf.c @@ -39,7 +39,7 @@ asprintf(char **str, const char *fmt, ...) f._bf._size = f._w = 127; /* Leave room for the NUL */ va_start(ap, fmt); ret = vfprintf(&f, fmt, ap); - va_end(ap); + va_end(ap); if (ret == -1) goto err; *f._p = '\0'; @@ -50,10 +50,7 @@ asprintf(char **str, const char *fmt, ...) return (ret); err: - if (f._bf._base) { - free(f._bf._base); - f._bf._base = NULL; - } + free(f._bf._base); *str = NULL; errno = ENOMEM; return (-1); -- 2.11.0