Page MenuHomeFreeBSD

D42710.diff
No OneTemporary

D42710.diff

diff --git a/lib/libc/gen/memfd_create.c b/lib/libc/gen/memfd_create.c
--- a/lib/libc/gen/memfd_create.c
+++ b/lib/libc/gen/memfd_create.c
@@ -35,7 +35,6 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -52,7 +51,8 @@
memfd_create(const char *name, unsigned int flags)
{
char memfd_name[NAME_MAX + 1];
- size_t namelen, *pgs, pgsize;
+ size_t pgs[MAXPAGESIZES];
+ size_t namelen, pgsize;
struct shm_largepage_conf slc;
int error, fd, npgs, oflags, pgidx, saved_errno, shmflags;
@@ -92,16 +92,9 @@
if (fd == -1 || (flags & MFD_HUGETLB) == 0)
return (fd);
- pgs = NULL;
- npgs = getpagesizes(NULL, 0);
+ npgs = getpagesizes(pgs, nitems(pgs));
if (npgs == -1)
goto clean;
- pgs = calloc(npgs, sizeof(size_t));
- if (pgs == NULL)
- goto clean;
- error = getpagesizes(pgs, npgs);
- if (error == -1)
- goto clean;
pgsize = (size_t)1 << ((flags & MFD_HUGE_MASK) >> MFD_HUGE_SHIFT);
for (pgidx = 0; pgidx < npgs; pgidx++) {
if (pgsize == pgs[pgidx])
@@ -111,8 +104,6 @@
errno = EOPNOTSUPP;
goto clean;
}
- free(pgs);
- pgs = NULL;
memset(&slc, 0, sizeof(slc));
slc.psind = pgidx;
@@ -125,7 +116,6 @@
clean:
saved_errno = errno;
close(fd);
- free(pgs);
errno = saved_errno;
return (-1);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 11, 5:58 AM (18 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15751096
Default Alt Text
D42710.diff (1 KB)

Event Timeline