aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/posix/tempname.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1996-10-02 01:40:17 +0000
committerUlrich Drepper <drepper@redhat.com>1996-10-02 01:40:17 +0000
commita68b0d31a37a86785b3dbeeee3fad96ee71fadcd (patch)
tree61537b1f028002a9e6e0f5354fced6128bda8b9c /sysdeps/posix/tempname.c
parent2d07133b507b13d4a5ed6dc250f4345c8a26942a (diff)
downloadglibc-a68b0d31a37a86785b3dbeeee3fad96ee71fadcd.zip
glibc-a68b0d31a37a86785b3dbeeee3fad96ee71fadcd.tar.gz
glibc-a68b0d31a37a86785b3dbeeee3fad96ee71fadcd.tar.bz2
update from main archive 961001
Diffstat (limited to 'sysdeps/posix/tempname.c')
-rw-r--r--sysdeps/posix/tempname.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
index d58024f..61774a0 100644
--- a/sysdeps/posix/tempname.c
+++ b/sysdeps/posix/tempname.c
@@ -150,7 +150,7 @@ __stdio_gen_tempname (char *buf, size_t bufsize, const char *dir,
len = dlen + 1 + plen + 5 + 3;
while (1)
{
- const size_t i;
+ size_t i;
if (*idx >= ((sizeof (letters) - 1) * (sizeof (letters) - 1) *
(sizeof (letters) - 1)))
@@ -193,11 +193,18 @@ __stdio_gen_tempname (char *buf, size_t bufsize, const char *dir,
Create a stream for it. */
#ifdef USE_IN_LIBIO
int save;
+ struct locked_FILE
+ {
+ struct _IO_FILE_plus fp;
+#ifdef _IO_MTSAFE_IO
+ _IO_lock_t lock;
+#endif
+ } *new_f;
struct _IO_FILE_plus *fp;
- fp = (struct _IO_FILE_plus *)
- malloc (sizeof (struct _IO_FILE_plus));
- if (fp == NULL)
+ new_f = (struct locked_FILE *)
+ malloc (sizeof (struct locked_FILE));
+ if (new_f == NULL)
{
/* We lost trying to create a stream (out of memory?).
Nothing to do but remove the file, close the descriptor,
@@ -209,6 +216,10 @@ __stdio_gen_tempname (char *buf, size_t bufsize, const char *dir,
__set_errno (save);
return NULL;
}
+ fp = &new_f->fp;
+#ifdef _IO_MTSAFE_IO
+ fp->file._lock = &new_f->lock;
+#endif
_IO_init (&fp->file, 0);
_IO_JUMPS (&fp->file) = &_IO_file_jumps;
_IO_file_init (&fp->file);