diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-06-15 06:24:21 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-06-15 06:24:21 (GMT) |
commit | 2db42544f80a9d5f0e30a0e7d09dfd98082a8a0b (patch) | |
tree | 509b20b120c8e29d5b625d8965237a043fd2d25b | |
parent | 5e2b640532f36e5ad5e616a52a371d20edd78d01 (diff) |
Compress packed run-length encoded strings.
-rw-r--r-- | src/analysis/db/misc/rlestr.c | 13 |
1 files 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 <string.h> +#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); |