From 1b5b13047cfe151692fd3ece47bd1e01d25773e6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 10 Sep 2024 22:12:12 +0200 Subject: Merging upstream version 1.47.1. Signed-off-by: Daniel Baumann --- src/libnetdata/gorilla/gorilla.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/libnetdata') diff --git a/src/libnetdata/gorilla/gorilla.cc b/src/libnetdata/gorilla/gorilla.cc index c76018365..e3d612418 100644 --- a/src/libnetdata/gorilla/gorilla.cc +++ b/src/libnetdata/gorilla/gorilla.cc @@ -162,10 +162,11 @@ bool gorilla_writer_write(gorilla_writer_t *gw, uint32_t number) __atomic_fetch_add(&hdr->nbits, 1, __ATOMIC_RELAXED); if (!is_xor_lzc_same) { - if (hdr->nbits + 1 >= gw->capacity) + size_t bits_needed = (bit_size() == 32) ? 5 : 6; + if ((hdr->nbits + bits_needed) >= gw->capacity) return false; - bit_buffer_write(data, hdr->nbits, xor_lzc, (bit_size() == 32) ? 5 : 6); - __atomic_fetch_add(&hdr->nbits, (bit_size() == 32) ? 5 : 6, __ATOMIC_RELAXED); + bit_buffer_write(data, hdr->nbits, xor_lzc, bits_needed); + __atomic_fetch_add(&hdr->nbits, bits_needed, __ATOMIC_RELAXED); } // write the bits of the XOR'd value without the LZC prefix -- cgit v1.2.3