Use of M_CONST_CAST for array.
This commit is contained in:
1 parent
7e517f35c5
commit
b3a4ffb962
1 file changed
+2
-15
@@ -105,11 +105,6 @@
|
|||||||
type *ptr; \
|
type *ptr; \
|
||||||
} array_t[1]; \
|
} array_t[1]; \
|
||||||
\
|
\
|
||||||
typedef union { \
|
|
||||||
type *ptr; \
|
|
||||||
const type *cptr; \
|
|
||||||
} M_C3(array_union_, name,_t); \
|
|
||||||
\
|
|
||||||
typedef type M_C3(array_type_,name,_t); \
|
typedef type M_C3(array_type_,name,_t); \
|
||||||
\
|
\
|
||||||
typedef struct M_C3(array_it_,name,_s) { \
|
typedef struct M_C3(array_it_,name,_s) { \
|
||||||
@@ -117,14 +112,6 @@
|
|||||||
struct M_C3(array_, name, _s) *array; \
|
struct M_C3(array_, name, _s) *array; \
|
||||||
} array_it_t[1]; \
|
} array_it_t[1]; \
|
||||||
\
|
\
|
||||||
static inline const type * \
|
|
||||||
M_C3(array_, name, _const_cast)(type *ptr) \
|
|
||||||
{ \
|
|
||||||
M_C3(array_union_, name,_t) u; \
|
|
||||||
u.ptr = ptr; \
|
|
||||||
return u.cptr; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
static inline void \
|
static inline void \
|
||||||
M_C3(array_, name, _init)(array_t v) \
|
M_C3(array_, name, _init)(array_t v) \
|
||||||
{ \
|
{ \
|
||||||
@@ -224,7 +211,7 @@
|
|||||||
{ \
|
{ \
|
||||||
ARRAYI_CONTRACT(v); \
|
ARRAYI_CONTRACT(v); \
|
||||||
assert(v->size > 0 && v->ptr != NULL); \
|
assert(v->size > 0 && v->ptr != NULL); \
|
||||||
return M_C3(array_, name, _const_cast)(&v->ptr[v->size-1]); \
|
return M_CONST_CAST(type, &v->ptr[v->size-1]); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline type * \
|
static inline type * \
|
||||||
@@ -504,7 +491,7 @@
|
|||||||
{ \
|
{ \
|
||||||
ARRAYI_CONTRACT(v); \
|
ARRAYI_CONTRACT(v); \
|
||||||
assert (i < v->size && v->ptr != NULL); \
|
assert (i < v->size && v->ptr != NULL); \
|
||||||
return M_C3(array_, name, _const_cast)(&v->ptr[i]); \
|
return M_CONST_CAST(type, &v->ptr[i]); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline void \
|
static inline void \
|
||||||
|
|||||||
Reference in new issue
Block a user