From f7a89529330044f4e2a38e85a88ec90f839ae64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Wed, 25 Nov 2020 12:42:36 +0100 Subject: Add xReadfile wrapper for reading small to medium size files Inspired by proposed Linux syscall Avoid file descriptor leaks like 4af8c63f --- XUtils.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'XUtils.h') diff --git a/XUtils.h b/XUtils.h index a978a0ed..d004785f 100644 --- a/XUtils.h +++ b/XUtils.h @@ -14,6 +14,7 @@ in the source distribution for its full text. #include // IWYU pragma: keep #include // IWYU pragma: keep +#include "Compat.h" #include "Macros.h" @@ -63,4 +64,7 @@ char* xStrdup(const char* str) ATTR_NONNULL; char* xStrndup(const char* str, size_t len) ATTR_NONNULL; +ssize_t xReadfile(const char* pathname, void* buffer, size_t count); +ssize_t xReadfileat(openat_arg_t dirfd, const char* pathname, void* buffer, size_t count); + #endif -- cgit v1.2.3