Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Side by Side Diff: fusl/src/temp/mktemp.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/temp/mkstemps.c ('k') | fusl/src/termios/cfgetospeed.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #define _GNU_SOURCE
2 #include <string.h>
3 #include <stdlib.h>
4 #include <errno.h>
5 #include <sys/stat.h>
6
7 char *__randname(char *);
8
9 char *mktemp(char *template)
10 {
11 size_t l = strlen(template);
12 int retries = 100;
13 struct stat st;
14
15 if (l < 6 || memcmp(template+l-6, "XXXXXX", 6)) {
16 errno = EINVAL;
17 *template = 0;
18 return template;
19 }
20
21 do {
22 __randname(template+l-6);
23 if (stat(template, &st)) {
24 if (errno != ENOENT) *template = 0;
25 return template;
26 }
27 } while (--retries);
28
29 *template = 0;
30 errno = EEXIST;
31 return template;
32 }
OLDNEW
« no previous file with comments | « fusl/src/temp/mkstemps.c ('k') | fusl/src/termios/cfgetospeed.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698