blob: 145d7404f098e4752dbeaee370d04b389a059dc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include "stddef.h" // for NULL
#include <dirent.h>
#include <errno.h>
#include <libc/dirent.h>
#include <stdlib.h>
#include <sys/cdefs.h>
DIR *fdopendir(int fildes)
{
struct __DIR *dir;
if (__predict_false(fildes < 0)) {
errno = EBADF;
return NULL;
}
dir = calloc(1, sizeof(struct __DIR));
if (__predict_false(dir == NULL)) {
return NULL;
}
dir->fildes = fildes;
return dir;
}
|