File:  [MW Coherent from dump] / coherent / b / lib / libc / stdio / tmpfile.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * libc/stdio/tmpfile.c
 * ANSI-compliant C standard i/o library.
 * tmpfile()
 * ANSI 4.9.4.3.
 * Create a temporary stream.
 */

#include <stdio.h>
#include <stdlib.h>

FILE *
tmpfile()
{
	register char *name;
	register FILE *fp;

	/* Allocate file name buffer. */
	if ((name = malloc((size_t)L_tmpnam)) == NULL)
		return NULL;

	/* Generate a temporary file name and open the temp file. */
	if ((fp = fopen(tmpnam(name), "w+b")) == NULL) {
		free(name);
		return NULL;
	}

	/*
	 * Save the name.
	 * The temp file will be removed and the name buffer freed when closed.
	 */
	fp->_f2p->_nm = name;
	return fp;
}

/* 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.