From 2c86b2bc6e6b28dc8c6bf0384e90d1eb4a05af8d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 10 Sep 1998 13:11:25 +0000 Subject: Update. 1998-09-10 Ulrich Drepper * stdio-common/tmpnam.c: Move local static variable buf to toplevel and rename to tmpnam_buffer to ease debugging. Patch by Joe Keane . Optimize s == NULL case a bit. --- stdio-common/tmpnam.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'stdio-common') diff --git a/stdio-common/tmpnam.c b/stdio-common/tmpnam.c index e5c6bf166d..0bbb318953 100644 --- a/stdio-common/tmpnam.c +++ b/stdio-common/tmpnam.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1993, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,6 +19,8 @@ #include #include +static char tmpnam_buffer[L_tmpnam]; + /* Generate a unique filename in P_tmpdir. This function is *not* thread safe! */ @@ -27,7 +29,6 @@ tmpnam (char *s) { /* By using two buffers we manage to be thread safe in the case where S != NULL. */ - static char buf[L_tmpnam]; char tmpbuf[L_tmpnam]; /* In the following call we use the buffer pointed to by S if @@ -40,10 +41,7 @@ tmpnam (char *s) return NULL; if (s == NULL) - { - memcpy (buf, tmpbuf, L_tmpnam); - return buf; - } - else - return s; + return (char *) memcpy (tmpnam_buffer, tmpbuf, L_tmpnam); + + return s; } -- cgit 1.4.1