From 6e9880366fb2d6cccca532262e4c8218860203e4 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 14 Aug 2026 11:40:24 +0200 Subject: [PATCH] Revert "uint-bset: add slot0 member" This reverts commit 743096a4964bf921f7b39cc7b739fd4fab6ad39c. Closes #22581 --- lib/uint-bset.c | 21 ++++++--------------- lib/uint-bset.h | 1 - tests/unit/unit3211.c | 5 ----- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/lib/uint-bset.c b/lib/uint-bset.c index f734f86ffd..55aedb234b 100644 --- a/lib/uint-bset.c +++ b/lib/uint-bset.c @@ -44,22 +44,14 @@ CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax) DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC); if(nslots != bset->nslots) { - uint64_t *slots; - if(nslots > 1) { - slots = curlx_calloc(nslots, sizeof(uint64_t)); - if(!slots) - return CURLE_OUT_OF_MEMORY; - } - else { - bset->slot0 = 0; - slots = &bset->slot0; - } + uint64_t *slots = curlx_calloc(nslots, sizeof(uint64_t)); + if(!slots) + return CURLE_OUT_OF_MEMORY; - if((bset->slots != slots) && nslots && bset->nslots) { + if(bset->slots) { memcpy(slots, bset->slots, (CURLMIN(nslots, bset->nslots) * sizeof(uint64_t))); - if(bset->slots != &bset->slot0) - curlx_free(bset->slots); + curlx_free(bset->slots); } bset->slots = slots; bset->nslots = nslots; @@ -71,8 +63,7 @@ CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax) void Curl_uint32_bset_destroy(struct uint32_bset *bset) { DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC); - if(bset->slots != &bset->slot0) - curlx_free(bset->slots); + curlx_free(bset->slots); memset(bset, 0, sizeof(*bset)); } diff --git a/lib/uint-bset.h b/lib/uint-bset.h index d4e2972ad1..ce0450c53c 100644 --- a/lib/uint-bset.h +++ b/lib/uint-bset.h @@ -39,7 +39,6 @@ struct uint32_bset { uint64_t *slots; - uint64_t slot0; uint32_t nslots; uint32_t first_slot_used; #ifdef DEBUGBUILD diff --git a/tests/unit/unit3211.c b/tests/unit/unit3211.c index fea99301a1..0d1dde200d 100644 --- a/tests/unit/unit3211.c +++ b/tests/unit/unit3211.c @@ -126,10 +126,6 @@ static CURLcode test_unit3211(const char *arg) { UNITTEST_BEGIN_SIMPLE - static const uint32_t s0[] = { - /* spread numbers, some at slot edges */ - 0, 1, 4, 5, 8, 13, 17, 23, 24, 63, - }; static const uint32_t s1[] = { /* spread numbers, some at slot edges */ 0, 1, 4, 17, 63, 64, 65, 66, 90, 99, @@ -146,7 +142,6 @@ static CURLcode test_unit3211(const char *arg) 120, 121, 122, 123, 124, 125, 126, 127, }; - check_set("s0", 64, s0, CURL_ARRAYSIZE(s1)); check_set("s1", 100, s1, CURL_ARRAYSIZE(s1)); check_set("s2", 1000, s2, CURL_ARRAYSIZE(s2));