Work around static analyzer
that raise an issue on freeing non heap pointer
This commit is contained in:
1 parent
2ee40339b0
commit
5841f936e6
1 file changed
+14
-13
+14
-13
@@ -183,9 +183,9 @@ M_INLINE int m_shar3d_integer_cref(int *p) { return *p; }
|
|||||||
typedef shared_t M_F(name, _ct); \
|
typedef shared_t M_F(name, _ct); \
|
||||||
typedef type M_F(name, _subtype_ct); \
|
typedef type M_F(name, _subtype_ct); \
|
||||||
\
|
\
|
||||||
typedef struct M_F(name, combine_s) { \
|
typedef struct M_F(name, _combine_s) { \
|
||||||
type data; \
|
|
||||||
struct M_F(name, _s) ptr; \
|
struct M_F(name, _s) ptr; \
|
||||||
|
type data; \
|
||||||
} M_F(name, combine_ct)[1]; \
|
} M_F(name, combine_ct)[1]; \
|
||||||
|
|
||||||
/* Define the core functions */
|
/* Define the core functions */
|
||||||
@@ -224,18 +224,18 @@ M_INLINE int m_shar3d_integer_cref(int *p) { return *p; }
|
|||||||
M_F(name, _init_new)(shared_t shared) \
|
M_F(name, _init_new)(shared_t shared) \
|
||||||
{ \
|
{ \
|
||||||
/* NOTE: Alloc 1 struct with both structures. */ \
|
/* NOTE: Alloc 1 struct with both structures. */ \
|
||||||
struct M_F(name, combine_s) *p = \
|
struct M_F(name, _combine_s) *p = \
|
||||||
M_CALL_NEW(oplist, struct M_F(name, combine_s)); \
|
M_CALL_NEW(oplist, struct M_F(name, _combine_s)); \
|
||||||
if (M_UNLIKELY_NOMEM (p == NULL)) { \
|
if (M_UNLIKELY_NOMEM (p == NULL)) { \
|
||||||
M_MEMORY_FULL(sizeof(struct M_F(name, combine_s))); \
|
M_MEMORY_FULL(sizeof(struct M_F(name, _combine_s))); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
struct M_F(name, _s) *ptr = &p->ptr; \
|
struct M_F(name, _s) *ptr = &p->ptr; \
|
||||||
|
ptr->combineAlloc = true; \
|
||||||
type *data = &p->data; \
|
type *data = &p->data; \
|
||||||
M_CALL_INIT( oplist, *data); \
|
M_CALL_INIT( oplist, *data); \
|
||||||
ptr->data = data; \
|
ptr->data = data; \
|
||||||
M_CALL_INIT_SET(cpt_oplist, &ptr->cpt, 1); \
|
M_CALL_INIT_SET(cpt_oplist, &ptr->cpt, 1); \
|
||||||
ptr->combineAlloc = true; \
|
|
||||||
*shared = ptr; \
|
*shared = ptr; \
|
||||||
M_SHAR3D_CONTRACT(shared, cpt_oplist); \
|
M_SHAR3D_CONTRACT(shared, cpt_oplist); \
|
||||||
} \
|
} \
|
||||||
@@ -274,9 +274,10 @@ M_INLINE int m_shar3d_integer_cref(int *p) { return *p; }
|
|||||||
first element, aka data itself. Static analyzer tools don't \
|
first element, aka data itself. Static analyzer tools don't \
|
||||||
seem to detect this and report error. */ \
|
seem to detect this and report error. */ \
|
||||||
M_CALL_CLEAR(oplist, *(*dest)->data); \
|
M_CALL_CLEAR(oplist, *(*dest)->data); \
|
||||||
M_CALL_DEL(oplist, (*dest)->data); \
|
if (combineAlloc == false) { \
|
||||||
if (combineAlloc == false) \
|
M_CALL_DEL(oplist, (*dest)->data); \
|
||||||
M_CALL_DEL(oplist, *dest); \
|
} \
|
||||||
|
M_CALL_DEL(oplist, *dest); \
|
||||||
} \
|
} \
|
||||||
*dest = NULL; \
|
*dest = NULL; \
|
||||||
} \
|
} \
|
||||||
@@ -370,18 +371,18 @@ M_INLINE int m_shar3d_integer_cref(int *p) { return *p; }
|
|||||||
M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type) ) \
|
M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type) ) \
|
||||||
{ \
|
{ \
|
||||||
/* NOTE: Alloc 1 struct with both structures. */ \
|
/* NOTE: Alloc 1 struct with both structures. */ \
|
||||||
struct M_F(name, combine_s) *p = \
|
struct M_F(name, _combine_s) *p = \
|
||||||
M_CALL_NEW(oplist, struct M_F(name, combine_s)); \
|
M_CALL_NEW(oplist, struct M_F(name, _combine_s)); \
|
||||||
if (M_UNLIKELY_NOMEM (p == NULL)) { \
|
if (M_UNLIKELY_NOMEM (p == NULL)) { \
|
||||||
M_MEMORY_FULL(sizeof(struct M_F(name, combine_s))); \
|
M_MEMORY_FULL(sizeof(struct M_F(name, _combine_s))); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
struct M_F(name, _s) *ptr = &p->ptr; \
|
struct M_F(name, _s) *ptr = &p->ptr; \
|
||||||
|
ptr->combineAlloc = true; \
|
||||||
M_F(name, _subtype_ct) *data = &p->data; \
|
M_F(name, _subtype_ct) *data = &p->data; \
|
||||||
M_EMPLACE_CALL_FUNC(a, init_func, oplist, *data, exp_emplace_type); \
|
M_EMPLACE_CALL_FUNC(a, init_func, oplist, *data, exp_emplace_type); \
|
||||||
ptr->data = data; \
|
ptr->data = data; \
|
||||||
M_CALL_INIT_SET(cpt_oplist, &ptr->cpt, 1); \
|
M_CALL_INIT_SET(cpt_oplist, &ptr->cpt, 1); \
|
||||||
ptr->combineAlloc = true; \
|
|
||||||
*shared = ptr; \
|
*shared = ptr; \
|
||||||
M_SHAR3D_CONTRACT(shared, cpt_oplist); \
|
M_SHAR3D_CONTRACT(shared, cpt_oplist); \
|
||||||
} \
|
} \
|
||||||
|
|||||||
Reference in new issue
Block a user