Make list functions exception aware
This commit is contained in:
1 parent
aa055d0b00
commit
be4ff6f94d
1 file changed
+32
-19
@@ -294,7 +294,10 @@
|
|||||||
type *data = M_F(name, _push_raw)(v); \
|
type *data = M_F(name, _push_raw)(v); \
|
||||||
if (M_UNLIKELY (data == NULL)) \
|
if (M_UNLIKELY (data == NULL)) \
|
||||||
return; \
|
return; \
|
||||||
M_CALL_INIT_SET(oplist, *data, x); \
|
M_IF_EXCEPTION(struct M_F(name, _s) *next = *v ); \
|
||||||
|
M_ON_EXCEPTION( *v = next->next, M_C3(m_l1st_,name,_del)(next)) { \
|
||||||
|
M_CALL_INIT_SET(oplist, *data, x); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
M_IF_METHOD(INIT, oplist)( \
|
M_IF_METHOD(INIT, oplist)( \
|
||||||
@@ -304,7 +307,10 @@
|
|||||||
type *data = M_F(name, _push_raw)(v); \
|
type *data = M_F(name, _push_raw)(v); \
|
||||||
if (M_UNLIKELY (data == NULL)) \
|
if (M_UNLIKELY (data == NULL)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
M_CALL_INIT(oplist, *data); \
|
M_IF_EXCEPTION(struct M_F(name, _s) *next = *v ); \
|
||||||
|
M_ON_EXCEPTION( *v = next->next, M_C3(m_l1st_,name,_del)(next)) { \
|
||||||
|
M_CALL_INIT(oplist, *data); \
|
||||||
|
} \
|
||||||
return data; \
|
return data; \
|
||||||
} \
|
} \
|
||||||
, /* No INIT */) \
|
, /* No INIT */) \
|
||||||
@@ -534,23 +540,28 @@
|
|||||||
M_F(name, _init_set)(list_t list, const list_t org) \
|
M_F(name, _init_set)(list_t list, const list_t org) \
|
||||||
{ \
|
{ \
|
||||||
M_L1ST_CONTRACT(org); \
|
M_L1ST_CONTRACT(org); \
|
||||||
struct M_F(name, _s) *next, *it_org; \
|
struct M_F(name, _s) *m_volatile next = NULL; \
|
||||||
struct M_F(name, _s) **update_list; \
|
/* On exceptions, free node and clear list*/ \
|
||||||
update_list = list; \
|
M_ON_EXCEPTION(M_C3(m_l1st_,name,_del)(next), M_F(name, _clear)(list) ) { \
|
||||||
it_org = *org; \
|
struct M_F(name, _s) *it_org; \
|
||||||
while (it_org != NULL) { \
|
struct M_F(name, _s) **update_list; \
|
||||||
next = M_C3(m_l1st_,name,_new)(); \
|
update_list = list; \
|
||||||
*update_list = next; \
|
it_org = *org; \
|
||||||
if (M_UNLIKELY_NOMEM (next == NULL)) { \
|
while (it_org != NULL) { \
|
||||||
M_MEMORY_FULL(sizeof (struct M_F(name, _s))); \
|
next = M_C3(m_l1st_,name,_new)(); \
|
||||||
/* FIXME: Partially initialized list. What to do? */ \
|
if (M_UNLIKELY_NOMEM (next == NULL)) { \
|
||||||
return; \
|
M_MEMORY_FULL(sizeof (struct M_F(name, _s))); \
|
||||||
|
*update_list = NULL; \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
M_CALL_INIT_SET(oplist, next->data, it_org->data); \
|
||||||
|
*update_list = next; \
|
||||||
|
update_list = &next->next; \
|
||||||
|
it_org = it_org->next; \
|
||||||
|
M_IF_EXCEPTION(next = NULL, *update_list = NULL); \
|
||||||
} \
|
} \
|
||||||
update_list = &next->next; \
|
*update_list = NULL; \
|
||||||
M_CALL_INIT_SET(oplist, next->data, it_org->data); \
|
|
||||||
it_org = it_org->next; \
|
|
||||||
} \
|
} \
|
||||||
*update_list = NULL; \
|
|
||||||
M_L1ST_CONTRACT(list); \
|
M_L1ST_CONTRACT(list); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
@@ -558,8 +569,10 @@
|
|||||||
M_F(name, _set)(list_t list, const list_t org) \
|
M_F(name, _set)(list_t list, const list_t org) \
|
||||||
{ \
|
{ \
|
||||||
if (M_UNLIKELY (list == org)) return; \
|
if (M_UNLIKELY (list == org)) return; \
|
||||||
M_F(name, _clear)(list); \
|
M_ON_EXCEPTION(M_F(name, _init)(list) ) { \
|
||||||
M_F(name, _init_set)(list, org); \
|
M_F(name, _clear)(list); \
|
||||||
|
M_F(name, _init_set)(list, org); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
M_INLINE void \
|
M_INLINE void \
|
||||||
|
|||||||
Reference in new issue
Block a user