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

This commit is contained in:
Patrick Pelissier committed 2021-10-28 17:32:02 +02:00
1 parent 9176953a8e
commit f172bbaad2
3 files changed
+18 -12

No files matched your search

+2 -2
View File
@@ -1636,9 +1636,9 @@ After-wise 'ref' is cleared.
Clear the array 'array (aka destructor).
##### void name\_clean(name\_t array)
##### void name\_reset(name\_t array)
Clean the array (the array becomes empty but remains initialized).
Reset the array (the array becomes empty but remains initialized).
##### type *name\_push\_raw(name\_t array)
+12 -6
View File
@@ -106,7 +106,7 @@
,IT_CREF(M_C(name,_cref)) \
,M_IF_METHOD(INIT_SET, oplist)(IT_INSERT(M_C(name,_insert)) ,) \
,M_IF_AT_LEAST_METHOD(SET,INIT_MOVE,oplist)(IT_REMOVE(M_C(name,_remove)),) \
,CLEAN(M_C(name,_clean)) \
,CLEAN(M_C(name,_reset)) \
,KEY_TYPE(size_t) \
,VALUE_TYPE(M_C(name, _subtype_ct)) \
,KEY_OPLIST(M_DEFAULT_OPLIST) \
@@ -198,7 +198,7 @@
} \
\
static inline void \
M_C(name, _clean)(array_t v) \
M_C(name, _reset)(array_t v) \
{ \
M_ARRA4_CONTRACT(v); \
for(size_t i = 0; i < v->size; i++) \
@@ -207,11 +207,17 @@
M_ARRA4_CONTRACT(v); \
} \
\
static inline void M_ATTR_DEPRECATED \
M_C(name, _clean)(array_t v) \
{ \
M_C(name, _reset)(v); \
} \
\
static inline void \
M_C(name, _clear)(array_t v) \
{ \
M_ARRA4_CONTRACT(v); \
M_C(name, _clean)(v); \
M_C(name, _reset)(v); \
M_CALL_FREE(oplist, v->ptr); \
/* This is so reusing the object implies an assertion failure */ \
v->alloc = 1; \
@@ -933,7 +939,7 @@
{ \
M_ARRA4_CONTRACT(array); \
M_ASSERT (str != NULL); \
M_C(name,_clean)(array); \
M_C(name,_reset)(array); \
bool success = false; \
int c = *str++; \
if (M_UNLIKELY (c != '[')) goto exit; \
@@ -965,7 +971,7 @@
{ \
M_ARRA4_CONTRACT(array); \
M_ASSERT (file != NULL); \
M_C(name,_clean)(array); \
M_C(name,_reset)(array); \
int c = fgetc(file); \
if (M_UNLIKELY (c != '[')) return false; \
c = fgetc(file); \
@@ -1016,7 +1022,7 @@
m_serial_return_code_t ret; \
m_serial_local_t local; \
size_t estimated_size = 0; \
M_C(name,_clean)(array); \
M_C(name,_reset)(array); \
ret = f->m_interface->read_array_start(local, f, &estimated_size); \
if (M_UNLIKELY (ret != M_SERIAL_OK_CONTINUE)) { \
return ret; \
+4 -4
View File
@@ -162,12 +162,12 @@ static void test_uint(void)
array_uint_set (v2, v);
assert(array_uint_size(v2) == 1005);
array_uint_clean(v);
array_uint_reset(v);
assert (array_uint_capacity(v) > 0);
array_uint_reserve(v, 0);
assert (array_uint_capacity(v) == 0);
array_uint_clean(v2);
array_uint_reset(v2);
array_uint_splice(v, v2);
assert (array_uint_size(v) == 0);
assert (array_uint_size(v2) == 0);
@@ -244,7 +244,7 @@ static void test_mpz(void)
assert (array_mpz_equal_p (array1, array2));
fclose(f);
array_mpz_clean(array1);
array_mpz_reset(array1);
M_LET(str, STRING_OPLIST) {
array_mpz_get_str(str, array1, false);
@@ -353,7 +353,7 @@ static void test_d(void)
size_t h = array_uint_hash(a2);
assert (h != 0);
array_uint_clean(a1);
array_uint_reset(a1);
array_uint_it(it, a1);
assert (array_uint_end_p (it));
assert (array_uint_last_p (it));