Annotation of coherent/b/lib/libc/XSTDIO/tmpfile.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * libc/stdio/tmpfile.c
                      3:  * ANSI-compliant C standard i/o library.
                      4:  * tmpfile()
                      5:  * ANSI 4.9.4.3.
                      6:  * Create a temporary stream.
                      7:  */
                      8: 
                      9: #include <stdio.h>
                     10: #include <stdlib.h>
                     11: 
                     12: FILE *
                     13: tmpfile()
                     14: {
                     15:        register char *name;
                     16:        register FILE *fp;
                     17: 
                     18:        /* Allocate file name buffer. */
                     19:        if ((name = malloc((size_t)L_tmpnam)) == NULL)
                     20:                return NULL;
                     21: 
                     22:        /* Generate a temporary file name and open the temp file. */
                     23:        if ((fp = fopen(tmpnam(name), "w+b")) == NULL) {
                     24:                free(name);
                     25:                return NULL;
                     26:        }
                     27: 
                     28:        /*
                     29:         * Save the name.
                     30:         * The temp file will be removed and the name buffer freed when closed.
                     31:         */
                     32:        fp->_f2p->_nm = name;
                     33:        return fp;
                     34: }
                     35: 
                     36: /* end of libc/stdio/tmpfile.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.