Update _back & _front to return a modifiable ptr

(There is no real reasons to return a const pointer).
This commit is contained in:
Patrick Pelissier committed 2021-07-03 23:59:19 +02:00
1 parent 690cef561c
commit ca8d4aa97a
3 files changed
+25 -25

No files matched your search

+15 -15
View File
@@ -958,9 +958,9 @@ The list can't be used anymore, except with a constructor.
Clean the list (the list becomes empty).
It is like CLEAR but the list remains initialized and empty.
##### const type *name\_back(const name\_t list)
##### type *name\_back(const name\_t list)
Return a constant pointer to the data stored in the back of the list.
Return a pointer to the data stored in the back of the list.
##### void name\_push\_back(name\_t list, const type value)
@@ -1244,9 +1244,9 @@ Clear the list 'list (aka destructor). The list can't be used anymore, except wi
Clean the list (the list becomes empty). The list remains initialized but is empty.
##### const type *name\_back(const name\_t list)
##### type *name\_back(const name\_t list)
Return a constant pointer to the data stored in the back of the list.
Return a pointer to the data stored in the back of the list.
##### void name\_push\_back(name\_t list, type value)
@@ -1587,13 +1587,13 @@ then remove the element 'key' from the array.
'key' shall be within the size of the array.
This method is created if the SET or INIT\_MOVE operator is provided.
##### const type *name\_front(const name\_t array)
##### type *name\_front(const name\_t array)
Return a constant pointer to the first element of the array.
Return a pointer to the first element of the array.
##### const type *name\_back(const name\_t array)
##### type *name\_back(const name\_t array)
Return a constant pointer to the last element of the array.
Return a pointer to the last element of the array.
##### void name\_set\_at(name\_t array, size\_t i, type value)
@@ -1866,15 +1866,15 @@ Clear the deque 'deque (aka destructor). The deque can't be used anymore, except
Clean the deque (the deque becomes empty). The deque remains initialized but is empty.
##### const type *name\_back(const name\_t deque)
##### type *name\_back(const name\_t deque)
Return a constant pointer to the data stored in the back of the deque.
Return a pointer to the data stored in the back of the deque.
##### void name\_push\_back(name\_t deque, type value)
Push a new element within the deque 'deque' with the value 'value' at the back of the deque.
##### type *name\_push\_back÷\_raw(name\_t deque)
##### type *name\_push\_back\_raw(name\_t deque)
Push at the back a new element within the deque 'deque' without initializing it and returns a pointer to the **non-initialized** data.
The first thing to do after calling this function is to initialize the data using the proper constructor. This enables to use a more specialized
@@ -1891,9 +1891,9 @@ Return a pointer to the initialized object.
Pop a element from the deque 'deque' and set *data to this value.
If data pointer is NULL, then the popped value is discarded.
##### const type *name\_front(const name\_t deque)
##### type *name\_front(const name\_t deque)
Return a constant pointer to the data stored in the front of the deque.
Return a pointer to the data stored in the front of the deque.
##### void name\_push\_front(name\_t deque, type value)
@@ -4327,11 +4327,11 @@ the cleared object will also be deleted.
##### type *name\_back(const name\_t list)
Return a constant pointer to the data stored in the back of the list.
Return a pointer to the data stored in the back of the list.
##### type *name\_front(const name\_t list)
Return a constant pointer to the data stored in the front of the list.
Return a pointer to the data stored in the front of the list.
##### void name\_push\_back(name\_t list, type *obj)
+4 -4
View File
@@ -283,13 +283,13 @@
} \
, /* No SET */) \
\
static inline type const * \
static inline type * \
M_C(name, _back)(array_t v) \
{ \
M_ARRA4_CONTRACT(v); \
M_ASSERT(v->ptr != NULL); \
M_ASSERT_INDEX(0, v->size); \
return M_CONST_CAST(type, &v->ptr[v->size-1]); \
return &v->ptr[v->size-1]; \
} \
\
static inline type * \
@@ -665,12 +665,12 @@
return M_CONST_CAST(type, &v->ptr[i]); \
} \
\
static inline type const * \
static inline type * \
M_C(name, _front)(const array_t v) \
{ \
M_ARRA4_CONTRACT(v); \
M_ASSERT_INDEX(0, v->size); \
return M_C(name, _cget)(v, 0); \
return M_C(name, _get)(v, 0); \
} \
\
static inline void \
+6 -6
View File
@@ -247,12 +247,12 @@
M_C(name, _clean)(v); \
} \
\
static inline type const * \
static inline type * \
M_C(name, _back)(const list_t v) \
{ \
M_L1ST_CONTRACT(v); \
M_ASSERT(*v != NULL); \
return M_CONST_CAST(type, &((*v)->data)); \
return &((*v)->data); \
} \
\
static inline type * \
@@ -961,12 +961,12 @@
M_C(name, _clean)(v); \
} \
\
static inline type const * \
static inline type * \
M_C(name, _back)(const list_t v) \
{ \
M_L1ST_DUAL_PUSH_CONTRACT(v); \
M_ASSERT (v->back != NULL); \
return M_CONST_CAST(type, &(v->back->data)); \
return &(v->back->data); \
} \
\
static inline type * \
@@ -1073,12 +1073,12 @@
M_L1ST_DUAL_PUSH_CONTRACT(v); \
} \
\
static inline type const * \
static inline type * \
M_C(name, _front)(list_t v) \
{ \
M_L1ST_DUAL_PUSH_CONTRACT(v); \
M_ASSERT (v->front != NULL); \
return M_CONST_CAST(type, &(v->front->data)); \
return &(v->front->data); \
} \
\
static inline type * \