Back to index

glibc  2.9
Functions | Variables
tmpnam.c File Reference
#include <stdio.h>
#include <string.h>

Go to the source code of this file.


char * tmpnam (char *s)


static char tmpnam_buffer [L_tmpnam]

Function Documentation

char* tmpnam ( char *  s)

Definition at line 28 of file tmpnam.c.

  /* By using two buffers we manage to be thread safe in the case
     where S != NULL.  */
  char tmpbufmem[L_tmpnam];
  char *tmpbuf = s ?: tmpbufmem;

  /* In the following call we use the buffer pointed to by S if
     non-NULL although we don't know the size.  But we limit the size
     to L_tmpnam characters in any case.  */
  if (__builtin_expect (__path_search (tmpbuf, L_tmpnam, NULL, NULL, 0),
    return NULL;

  if (__builtin_expect (__gen_tempname (tmpbuf, 0, __GT_NOCREATE), 0))
    return NULL;

  if (s == NULL)
    return (char *) memcpy (tmpnam_buffer, tmpbuf, L_tmpnam);

  return s;

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

char tmpnam_buffer[L_tmpnam] [static]

Definition at line 22 of file tmpnam.c.