Cleanup file descriptors

This commit is contained in:
topjohnwu
2017-05-08 03:11:14 +08:00
parent 58849f28a8
commit ea8cd98361
9 changed files with 51 additions and 22 deletions

View File

@@ -32,6 +32,14 @@ FILE *xfopen(const char *pathname, const char *mode) {
return fp;
}
FILE *xfdopen(int fd, const char *mode) {
FILE *fp = fdopen(fd, mode);
if (fp == NULL) {
PLOGE("fopen");
}
return fp;
}
int xopen2(const char *pathname, int flags) {
int fd = open(pathname, flags);
if (fd < 0) {