From ddc2e304022300a22e81cb51fa1aef8fc6b93bff Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 11 Jan 2025 19:04:04 +0000 Subject: [PATCH] util: Remove function to read file contents into a buffer Signed-off-by: Michael Tremer --- src/pakfire/util.c | 35 ----------------------------------- src/pakfire/util.h | 1 - 2 files changed, 36 deletions(-) diff --git a/src/pakfire/util.c b/src/pakfire/util.c index 5c3760df5..931a8974d 100644 --- a/src/pakfire/util.c +++ b/src/pakfire/util.c @@ -98,41 +98,6 @@ ERROR: return r; } -int pakfire_read_file_into_buffer(FILE* f, char** buffer, size_t* len) { - if (!f) - return -EBADF; - - int r = fseek(f, 0, SEEK_END); - if (r) - return r; - - // Save length of file - *len = ftell(f); - - // Go back to the start - r = fseek(f, 0, SEEK_SET); - if (r) - return r; - - // Allocate buffer - *buffer = malloc((sizeof(**buffer) * *len) + 1); - if (!*buffer) - return -ENOMEM; - - // Read content - fread(*buffer, *len, sizeof(**buffer), f); - - // Check we encountered any errors - r = ferror(f); - if (r) - return r; - - // Terminate the buffer - (*buffer)[*len] = '\0'; - - return 0; -} - /* Maps a file descriptor into memory */ diff --git a/src/pakfire/util.h b/src/pakfire/util.h index 6310face7..fc7ea821e 100644 --- a/src/pakfire/util.h +++ b/src/pakfire/util.h @@ -42,7 +42,6 @@ static inline void* pakfire_realloc(void* p, size_t size) { return n; } -int pakfire_read_file_into_buffer(FILE* f, char** buffer, size_t* len); int pakfire_mmap(int fd, char** data, size_t* length); const char* pakfire_path_relpath(const char* root, const char* path); -- 2.47.3