From 2db42544f80a9d5f0e30a0e7d09dfd98082a8a0b Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Tue, 15 Jun 2021 08:24:21 +0200 Subject: Compress packed run-length encoded strings. --- src/analysis/db/misc/rlestr.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/analysis/db/misc/rlestr.c b/src/analysis/db/misc/rlestr.c index bb81b55..b93304b 100644 --- a/src/analysis/db/misc/rlestr.c +++ b/src/analysis/db/misc/rlestr.c @@ -29,6 +29,9 @@ #include +#include "../../../common/leb128.h" + + /****************************************************************************** * * @@ -276,16 +279,16 @@ int cmp_rle_string(const rle_string *s1, const rle_string *s2) bool unpack_rle_string(rle_string *str, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ - uint32_t tmp32; /* Valeur sur 32 bits */ + uleb128_t len; /* Quantité de caractères */ unset_rle_string(str); - result = extract_packed_buffer(pbuf, &tmp32, sizeof(uint32_t), true); - - str->length = tmp32; + result = unpack_uleb128(&len, pbuf); if (result && str->length > 0) { + str->length = len; + str->data = malloc(str->length + 1); str->dynamic = true; @@ -321,7 +324,7 @@ bool pack_rle_string(const rle_string *str, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ - result = extend_packed_buffer(pbuf, (uint32_t []) { str->length }, sizeof(uint32_t), true); + result = pack_uleb128((uleb128_t []){ str->length }, pbuf); if (result && str->length > 0) result = extend_packed_buffer(pbuf, str->data, str->length + 1, false); -- cgit v0.11.2-87-g4458