Revert "uint-bset: add slot0 member"
No binary (build failed)
—
(log yok)
| @@ -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)); | |
| } | |
| @@ -39,7 +39,6 @@ | |
| struct uint32_bset { | |
| uint64_t *slots; | |
| - | uint64_t slot0; |
| uint32_t nslots; | |
| uint32_t first_slot_used; | |
| #ifdef DEBUGBUILD | |
| @@ -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)); | |