From 946eac4e737b572dc8d14d865e6415d3d0ef261f Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 11 Jan 2025 19:02:28 +0000 Subject: [PATCH] util: Map JSON strings into memory Signed-off-by: Michael Tremer --- src/pakfire/util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pakfire/util.c b/src/pakfire/util.c index 634c45f0c..5c3760df5 100644 --- a/src/pakfire/util.c +++ b/src/pakfire/util.c @@ -451,9 +451,10 @@ static struct json_object* pakfire_json_parse_file(struct pakfire_ctx* ctx, FILE struct json_object* json = NULL; char* buffer = NULL; size_t length = 0; + int r; - // Read everything into memory - int r = pakfire_read_file_into_buffer(f, &buffer, &length); + // Map everything into memory + r = pakfire_mmap(fileno(f), &buffer, &length); if (r) goto ERROR; @@ -462,7 +463,7 @@ static struct json_object* pakfire_json_parse_file(struct pakfire_ctx* ctx, FILE ERROR: if (buffer) - free(buffer); + munmap(buffer, length); return json; } -- 2.47.3