From: Michael Tremer Date: Sat, 11 Jan 2025 19:02:28 +0000 (+0000) Subject: util: Map JSON strings into memory X-Git-Tag: 0.9.30~412 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=946eac4e737b572dc8d14d865e6415d3d0ef261f;p=pakfire.git util: Map JSON strings into memory Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/util.c b/src/pakfire/util.c index 634c45f0..5c3760df 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; }