libc: try to skip memcpy in _gettemp
This commit is contained in:
parent
6fe328ace8
commit
b22fdf45ff
@ -123,6 +123,7 @@ _gettemp(int dfd, char *path, int *doopen, int domkdir, int slen, int oflags)
|
|||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
uint32_t rand;
|
uint32_t rand;
|
||||||
char carrybuf[MAXPATHLEN];
|
char carrybuf[MAXPATHLEN];
|
||||||
|
int saved;
|
||||||
|
|
||||||
if ((doopen != NULL && domkdir) || slen < 0 ||
|
if ((doopen != NULL && domkdir) || slen < 0 ||
|
||||||
(oflags & ~(O_APPEND | O_DIRECT | O_SHLOCK | O_EXLOCK | O_SYNC |
|
(oflags & ~(O_APPEND | O_DIRECT | O_SHLOCK | O_EXLOCK | O_SYNC |
|
||||||
@ -151,9 +152,7 @@ _gettemp(int dfd, char *path, int *doopen, int domkdir, int slen, int oflags)
|
|||||||
}
|
}
|
||||||
start = trv + 1;
|
start = trv + 1;
|
||||||
|
|
||||||
/* save first combination of random characters */
|
saved = 0;
|
||||||
memcpy(carrybuf, start, suffp - start);
|
|
||||||
|
|
||||||
oflags |= O_CREAT | O_EXCL | O_RDWR;
|
oflags |= O_CREAT | O_EXCL | O_RDWR;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (doopen) {
|
if (doopen) {
|
||||||
@ -170,6 +169,12 @@ _gettemp(int dfd, char *path, int *doopen, int domkdir, int slen, int oflags)
|
|||||||
} else if (lstat(path, &sbuf))
|
} else if (lstat(path, &sbuf))
|
||||||
return (errno == ENOENT);
|
return (errno == ENOENT);
|
||||||
|
|
||||||
|
/* save first combination of random characters */
|
||||||
|
if (!saved) {
|
||||||
|
memcpy(carrybuf, start, suffp - start);
|
||||||
|
saved = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we have a collision, cycle through the space of filenames */
|
/* If we have a collision, cycle through the space of filenames */
|
||||||
for (trv = start, carryp = carrybuf;;) {
|
for (trv = start, carryp = carrybuf;;) {
|
||||||
/* have we tried all possible permutations? */
|
/* have we tried all possible permutations? */
|
||||||
|
Loading…
Reference in New Issue
Block a user