-/* Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <stddef.h> /* For NULL. */
+#include <stdlib.h>
#include <utmp.h>
/* Local buffer to store the result. */
-static struct utmp buffer;
+libc_freeres_ptr (static struct utmp *buffer);
struct utmp *
{
struct utmp *result;
- if (__getutline_r (line, &buffer, &result) < 0)
+ if (buffer == NULL)
+ {
+ buffer = (struct utmp *) malloc (sizeof (struct utmp));
+ if (buffer == NULL)
+ return NULL;
+ }
+ if (__getutline_r (line, buffer, &result) < 0)
return NULL;
return result;
}
+libc_hidden_def (__getutline)
weak_alias (__getutline, getutline)