Rename BUFFER, I-LIST, PRIOQUEUE & SHARED _clean in _reset to avoid confusing _clean & _clear functions. See #97

This commit is contained in:
Patrick Pelissier committed 2021-10-28 18:08:07 +02:00
1 parent 826d251ffe
commit 836d892832
9 files changed
+51 -24

No files matched your search

+7 -7
View File
@@ -3536,9 +3536,9 @@ from 'ref' and clear 'ref'.
Set the Priority Queue 'queue' by stealing as resource as possible
from 'ref' and clear 'ref'.
##### void name\_clean(name\_t queue)
##### void name\_reset(name\_t queue)
Clean the Priority Queue 'queue'. 'queue' remains initialized but empty.
Reset the Priority Queue 'queue' (It remains initialized but empty).
##### size\_t name\_size(const name\_t queue)
@@ -3716,9 +3716,9 @@ Clear the buffer and destroy all its allocation.
This function is not thread safe and doesn't perform any synchronization:
all threads shall have stopped using the buffer.
##### void name\_clean(buffer\_t buffer)
##### void name\_reset(buffer\_t buffer)
Clean the buffer making it empty but remain initialized.
Reset the buffer, making it empty but initialized.
This function is thread safe if the buffer was built thread safe.
##### bool name\_empty\_p(const buffer\_t buffer)
@@ -4247,11 +4247,11 @@ the shared pointer loses its ownership of the object and
it destroys it if no longer any other shared pointers own the object.
This function is thread safe.
##### void name\_clean(shared\_t shared)
##### void name\_reset(shared\_t shared)
'shared' loses ownership of its object and destroy it
'shared' loses ownership of its object and destroys it
if no longer any other shared pointers own it.
Then it makes the shared pointer 'shared' references NULL
Then it makes the shared pointer 'shared' references no object (NULL)
(it doesn't reference its object any-longer and loses its ownership of it).
This function is thread safe.
+8 -2
View File
@@ -375,7 +375,7 @@ M_C(name, _init)(buffer_t v, size_t size) \
} \
\
static inline void \
M_C(name, _clean)(buffer_t v) \
M_C(name, _reset)(buffer_t v) \
{ \
M_BUFF3R_CONTRACT(v,m_size); \
if (!M_BUFF3R_POLICY_P((policy), BUFFER_THREAD_UNSAFE)) { \
@@ -397,6 +397,12 @@ M_C(name, _init)(buffer_t v, size_t size) \
M_BUFF3R_CONTRACT(v,m_size); \
} \
\
static inline void M_ATTR_DEPRECATED \
M_C(name, _clean)(buffer_t v) \
{ \
M_C(name,_reset)(v); \
} \
\
static inline void \
M_C(name, _init_set)(buffer_t dest, const buffer_t src) \
{ \
@@ -1268,7 +1274,7 @@ M_C(name, _init)(buffer_t v, size_t size) \
,NAME(name) \
,TYPE(M_C(name,_ct)) \
,SUBTYPE(M_C(name, _subtype_ct)) \
,CLEAN(M_C(name,_clean)) \
,CLEAN(M_C(name,_reset)) \
,PUSH(M_C(name,_push)) \
,POP(M_C(name,_pop)) \
,OPLIST(oplist) \
+9 -3
View File
@@ -99,7 +99,7 @@ typedef struct m_ilist_head_s {
MOVE(M_C(name, _move)), \
NAME(name), \
TYPE(M_C(name,_ct)), \
CLEAN(M_C(name,_clean)), \
CLEAN(M_C(name,_reset)), \
SUBTYPE(M_C(name,_subtype_ct)), \
EMPTY_P(M_C(name,_empty_p)), \
IT_TYPE(M_C(name,_it_ct)), \
@@ -196,7 +196,7 @@ typedef struct m_ilist_head_s {
} \
\
static inline void \
M_C(name, _clean)(list_t list) \
M_C(name, _reset)(list_t list) \
{ \
M_IL1ST_CONTRACT(name, list); \
for(struct m_ilist_head_s *it = list->name.next, *next ; \
@@ -217,11 +217,17 @@ typedef struct m_ilist_head_s {
M_IL1ST_CONTRACT(name, list); \
} \
\
static inline void M_ATTR_DEPRECATED \
M_C(name, _clean)(list_t list) \
{ \
M_C(name,_reset)(list); \
} \
\
static inline void \
M_C(name, _clear)(list_t list) \
{ \
/* Nothing to do more than clean the list itself */ \
M_C(name, _clean)(list); \
M_C(name, _reset)(list); \
/* For safety purpose (create invalid represenation of object) */ \
list->name.next = NULL; \
list->name.prev = NULL; \
+8 -2
View File
@@ -83,7 +83,7 @@
,NAME(name) \
,TYPE(M_C(name,_ct)) \
,SUBTYPE(M_C(name, _subtype_ct)) \
,CLEAN(M_C(name,_clean)) \
,CLEAN(M_C(name,_reset)) \
,PUSH(M_C(name,_push)) \
,POP(M_C(name,_pop)) \
,OPLIST(oplist) \
@@ -186,9 +186,15 @@
} \
\
static inline void \
M_C(name, _reset)(prioqueue_t p) \
{ \
M_C(name, _array_reset)(p->array); \
} \
\
static inline void M_ATTR_DEPRECATED \
M_C(name, _clean)(prioqueue_t p) \
{ \
M_C(name, _array_clean)(p->array); \
M_C(name,_reset)(p); \
} \
\
static inline size_t \
+8 -2
View File
@@ -112,7 +112,7 @@ M_BEGIN_PROTECTED_CODE
INIT_SET(M_C(name, _init_set)), \
SET(M_C(name, _set)) \
INIT_MOVE(M_C(name, _init_move)), \
CLEAN(M_C(name, _clean)), \
CLEAN(M_C(name, _reset)), \
MOVE(M_C(name, _move)), \
SWAP(M_C(name, _swap)) \
,NAME(name) \
@@ -271,12 +271,18 @@ static inline int m_shar3d_integer_cref(int *p) { return *p; }
} \
\
static inline void \
M_C(name, _clean)(shared_t dest) \
M_C(name, _reset)(shared_t dest) \
{ \
/* NOTE: Clear will also set dest to NULL */ \
M_C(name, _clear)(dest); \
} \
\
static inline void M_ATTR_DEPRECATED \
M_C(name, _clean)(shared_t dest) \
{ \
M_C(name, _reset)(dest); \
} \
\
static inline void \
M_C(name, _set)(shared_t dest, \
const shared_t shared) \
+3 -3
View File
@@ -125,7 +125,7 @@ static void test_global(void)
assert (!buffer_uint_full_p(g_buff));
assert (buffer_uint_size(g_buff) == 0);
buffer_uint_clean(g_buff);
buffer_uint_reset(g_buff);
assert (buffer_uint_empty_p(g_buff));
assert (!buffer_uint_full_p(g_buff));
assert (buffer_uint_size(g_buff) == 0);
@@ -145,7 +145,7 @@ static void test_global(void)
assert (buffer_uint_size(g_buff) == 10);
assert (buffer_uint_push_blocking(g_buff, 15, false) == false);
buffer_uint_clean(g_buff);
buffer_uint_reset(g_buff);
assert (buffer_uint_empty_p(g_buff));
assert (!buffer_uint_full_p(g_buff));
assert (buffer_uint_size(g_buff) == 0);
@@ -260,7 +260,7 @@ static void test_no_thread(void)
b = buffer_llong_push(buff, c);
assert (b == true);
buffer_llong_clean(buff);
buffer_llong_reset(buff);
assert (buffer_llong_empty_p(buff) == true);
buffer_llong_clear(buff);
+3
View File
@@ -135,6 +135,9 @@ static void test(void)
assert (ilist_tname_size (list) == 2);
assert (ilist_tname_cref(it1) == &x3);
assert (ilist_tname_previous_obj(list, &x3) == &x1);
ilist_tname_reset(list);
assert (ilist_tname_empty_p(list));
ilist_tname_clear(list);
}
+1 -1
View File
@@ -275,7 +275,7 @@ static void test_it(void)
int_pqueue_swap(p, q);
assert(int_pqueue_size(p) == 20);
assert(int_pqueue_size(q) == 21);
int_pqueue_clean(q);
int_pqueue_reset(q);
assert(!int_pqueue_equal_p(p, q));
assert(int_pqueue_empty_p(q));
assert(!int_pqueue_empty_p(p));
+4 -4
View File
@@ -59,14 +59,14 @@ static void test1(void)
shared_int_init_set(p2, p1);
assert(f(p2) == 12);
shared_int_clean(p1);
shared_int_reset(p1);
assert(shared_int_NULL_p(p1));
assert(!shared_int_NULL_p(p2));
assert(f(p2) == 12);
shared_int_set(p1, p2);
shared_int_clean(p2);
shared_int_reset(p2);
assert(!shared_int_NULL_p(p1));
assert(shared_int_NULL_p(p2));
assert(f(p1) == 12);
@@ -75,8 +75,8 @@ static void test1(void)
assert(!shared_int_NULL_p(p2));
assert(f(p2) == 12);
shared_int_clean(p2);
shared_int_clean(p1);
shared_int_reset(p2);
shared_int_reset(p1);
assert(shared_int_NULL_p(p1));
assert(shared_int_NULL_p(p2));