]> git.ipfire.org Git - people/ric9/pakfire.git/commitdiff
util: Remove function to read file contents into a buffer
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Jan 2025 19:04:04 +0000 (19:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Jan 2025 19:04:04 +0000 (19:04 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/util.c
src/pakfire/util.h

index 5c3760df51665a44c4a443f3f5e702589437822b..931a8974db14350977a1798243d3a370fd48e296 100644 (file)
@@ -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
 */
index 6310face78a9ed911950e6d10956f64044cbd225..fc7ea821eb372a43cb2693fd00283c1cc667750e 100644 (file)
@@ -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);