Rename BITSET & CONCURRENT _clean in _reset to avoid confusing _clean & _clear functions. See #97

This commit is contained in:
Patrick Pelissier committed 2021-10-28 18:13:00 +02:00
1 parent 836d892832
commit e10c3586a3
5 files changed
+30 -17

No files matched your search

+6 -6
View File
@@ -4566,9 +4566,9 @@ Clear the list 'list (aka destructor). The list can't be used anymore, except wi
If the DEL operator is available in the oplist of the type,
the cleared object will also be deleted.
##### void name\_clean(name\_t list)
##### void name\_reset(name\_t list)
Clean the list (the list becomes empty). The list remains initialized but is empty.
Reset the list (the list becomes empty). The list remains initialized but is empty.
If the DEL operator is available in the oplist of the type,
the cleared object will also be deleted.
@@ -4784,9 +4784,9 @@ Set the container with the value of 'src' by stealing as much resources from 'sr
Afterwards 'src' is cleared.
This method is only defined if the base container exports the MOVE operator.
##### void name\_clean(name\_t concurrent)
##### void name\_reset(name\_t concurrent)
Clean the concurrent container.
Reset the concurrent container.
Afterwards the container is empty, but remains initialized.
This method is only defined if the base container exports the CLEAN operator.
@@ -4975,9 +4975,9 @@ Afterwards 'ref' is cleared.
Clear the bitset 'array (aka destructor).
##### void bitset\_clean(bitset\_t array)
##### void bitset\_reset(bitset\_t array)
Clean the bitset (the bitset becomes empty but remains initialized).
Reset the bitset (the bitset becomes empty but remains initialized).
##### void bitset\_push\_back(bitset\_t array, const bool value)
+11 -5
View File
@@ -94,17 +94,23 @@ bitset_init(bitset_t t)
/* Clean a bitset */
static inline void
bitset_clean(bitset_t t)
bitset_reset(bitset_t t)
{
M_B1TSET_CONTRACT(t);
t->size = 0;
}
static inline void M_ATTR_DEPRECATED
bitset_clean(bitset_t t)
{
bitset_reset(t);
}
/* Clear a bitset (DESTRUCTOR) */
static inline void
bitset_clear(bitset_t t)
{
bitset_clean(t);
bitset_reset(t);
M_MEMORY_FREE(t->ptr);
// This is not really needed, but is safer
// This representation is invalid and will be detected by the contract.
@@ -629,7 +635,7 @@ bitset_in_str(bitset_t set, FILE *file)
{
M_B1TSET_CONTRACT (set);
M_ASSERT(file != NULL);
bitset_clean(set);
bitset_reset(set);
int c = fgetc(file);
if (M_UNLIKELY (c != '[')) return false;
c = fgetc(file);
@@ -649,7 +655,7 @@ bitset_parse_str(bitset_t set, const char str[], const char **endptr)
M_B1TSET_CONTRACT (set);
M_ASSERT(str != NULL);
bool success = false;
bitset_clean(set);
bitset_reset(set);
char c = *str++;
if (M_UNLIKELY(c != '[')) goto exit;
c = *str++;
@@ -841,7 +847,7 @@ bitset_popcount(const bitset_t set)
,IT_NEXT(bitset_next) \
,IT_PREVIOUS(bitset_previous) \
,IT_CREF(bitset_cref) \
,CLEAN(bitset_clean) \
,CLEAN(bitset_reset) \
,PUSH(bitset_push_back) \
,POP(bitset_pop_back) \
,HASH(bitset_hash) \
+7 -2
View File
@@ -109,7 +109,7 @@
,OPLIST(oplist) \
,M_IF_METHOD(EMPTY_P, oplist)(EMPTY_P(M_C(name,_empty_p)),) \
,M_IF_METHOD(GET_SIZE, oplist)(GET_SIZE(M_C(name,_size)),) \
,M_IF_METHOD(CLEAN, oplist)(CLEAN(M_C(name,_clean)),) \
,M_IF_METHOD(CLEAN, oplist)(CLEAN(M_C(name,_reset)),) \
,M_IF_METHOD(KEY_TYPE, oplist)(KEY_TYPE(M_GET_KEY_TYPE oplist),) \
,M_IF_METHOD(VALUE_TYPE, oplist)(VALUE_TYPE(M_GET_VALUE_TYPE oplist),) \
,M_IF_METHOD(KEY_TYPE, oplist)(KEY_OPLIST(M_GET_KEY_OPLIST oplist),) \
@@ -416,13 +416,18 @@
\
M_IF_METHOD(CLEAN, oplist)( \
static inline void \
M_C(name, _clean)(concurrent_t out) \
M_C(name, _reset)(concurrent_t out) \
{ \
M_C0NCURRENT_CONTRACT(out); \
M_C(name, _write_lock)(out); \
M_CALL_CLEAN(oplist, out->data); \
M_C(name, _write_unlock)(out); \
} \
static inline void M_ATTR_DEPRECATED \
M_C(name, _clean)(concurrent_t out) \
{ \
M_C(name,_reset)(out); \
} \
,) \
\
M_IF_METHOD(EMPTY_P, oplist)( \
+4 -4
View File
@@ -46,7 +46,7 @@ static void test1(void)
bitset_t set2;
bitset_init_set(set2, set);
bitset_clean(set);
bitset_reset(set);
assert(bitset_size(set) == 0);
assert(bitset_empty_p(set) == true);
@@ -135,7 +135,7 @@ static void test1(void)
assert (*sp == 0);
bitset_clear(set3);
bitset_clean(set);
bitset_reset(set);
for(int i = 0; i < 200; i++)
bitset_push_back(set, ((size_t) i*17547854547UL)&1) ;
bitset_it_t it;
@@ -164,7 +164,7 @@ static void test1(void)
bitset_reserve(set, 0);
assert(bitset_capacity (set) > 0);
bitset_clean(set);
bitset_reset(set);
bitset_reserve(set, 0);
assert(bitset_capacity (set) == 0);
@@ -217,7 +217,7 @@ static void test1(void)
assert (bitset_hash(set) != 0);
bitset_clean(set);
bitset_reset(set);
bitset_it(it, set);
assert(bitset_end_p(it));
assert(bitset_last_p(it));
+2
View File
@@ -217,10 +217,12 @@ static void test_double(void)
{
ConcurrentDouble d;
ConcurrentDouble_init(d);
ConcurrentDouble_reset(d);
ConcurrentDouble_clear(d);
ConcurrentRpDouble r;
ConcurrentRpDouble_init(r);
ConcurrentRpDouble_reset(r);
ConcurrentRpDouble_clear(r);
}