2727**/
2828static inline void __attribute__ ((nonnull)) cppq_inc_idx(uint16_t * const pIdx, const uint16_t end, const uint16_t start)
2929{
30- if (*pIdx < (end - 1U )) { (*pIdx)++; }
31- else { *pIdx = start; }
30+ if (*pIdx < (end - 1U ))
31+ {
32+ (*pIdx)++;
33+ }
34+ else
35+ {
36+ *pIdx = start;
37+ }
3238}
3339
3440/* ! \brief Decrement index
@@ -39,8 +45,14 @@ static inline void __attribute__((nonnull)) cppq_inc_idx(uint16_t * const pIdx,
3945**/
4046static inline void __attribute__ ((nonnull)) cppq_dec_idx(uint16_t * const pIdx, const uint16_t end, const uint16_t start)
4147{
42- if (*pIdx > start) { (*pIdx)--; }
43- else { *pIdx = end - 1U ; }
48+ if (*pIdx > start)
49+ {
50+ (*pIdx)--;
51+ }
52+ else
53+ {
54+ *pIdx = end - 1U ;
55+ }
4456}
4557
4658
@@ -81,18 +93,26 @@ inline uint16_t __attribute__((always_inline)) cppQueue::_getCount(void) const {
8193/* ***********************/
8294cppQueue::cppQueue (const size_t size_rec, const uint16_t nb_recs, const cppQueueType type, const bool overwrite, void * const pQDat, const size_t lenQDat)
8395{
96+ flush (); // variables needs to be 0 to ensure proper functions behavior when queue is not allocated
8497 init = 0 ;
85- rec_nb = 0 ; // rec_nb needs to be 0 to ensure proper push behavior when queue is not allocated
86- ovw = false ; // ovw needs to be false to ensure proper push behavior when queue is not allocated
87- flush (); // other variables needs to be 0 to ensure proper functions behavior when queue is not allocated
98+ rec_nb = 0 ; // rec_nb needs to be 0 to ensure proper push behavior when queue is not allocated
99+ ovw = false ; // ovw needs to be false to ensure proper push behavior when queue is not allocated
100+ dynamic = (pQDat == NULL );
88101
89102 const size_t size = nb_recs * size_rec;
90103
91- dynamic = (pQDat == NULL );
92-
93- if (dynamic) { queue = static_cast <uint8_t *>(malloc (size)); }
94- else if (lenQDat >= size) { queue = static_cast <uint8_t *>(pQDat); }
95- else { queue = NULL ; }
104+ if (dynamic)
105+ {
106+ queue = static_cast <uint8_t *>(malloc (size));
107+ }
108+ else if (lenQDat >= size)
109+ {
110+ queue = static_cast <uint8_t *>(pQDat);
111+ }
112+ else
113+ {
114+ queue = NULL ;
115+ }
96116
97117 if (queue != NULL )
98118 {
@@ -108,7 +128,10 @@ cppQueue::cppQueue(const size_t size_rec, const uint16_t nb_recs, const cppQueue
108128
109129cppQueue::~cppQueue ()
110130{
111- if (_isInitialized () && dynamic && (queue != NULL )) { free (queue); }
131+ if (_isInitialized () && dynamic && (queue != NULL ))
132+ {
133+ free (queue);
134+ }
112135}
113136
114137
@@ -147,7 +170,7 @@ bool __attribute__((nonnull)) cppQueue::push(const void * const record)
147170 if (ret)
148171 {
149172 uint8_t * const pStart = queue + (rec_sz * in);
150- memcpy (pStart, record, rec_sz);
173+ ( void ) memcpy (pStart, record, rec_sz);
151174 cppq_inc_idx (&in, rec_nb, 0 );
152175 }
153176
@@ -177,7 +200,7 @@ bool __attribute__((nonnull)) cppQueue::pop(void * const record)
177200 pStart = queue + (rec_sz * in);
178201 }
179202
180- memcpy (record, pStart, rec_sz);
203+ ( void ) memcpy (record, pStart, rec_sz);
181204 cnt--; // Decrease records count
182205 }
183206
@@ -209,7 +232,7 @@ bool __attribute__((nonnull)) cppQueue::peek(void * const record)
209232 pStart = queue + (rec_sz * rec);
210233 }
211234
212- memcpy (record, pStart, rec_sz);
235+ ( void ) memcpy (record, pStart, rec_sz);
213236 }
214237
215238 return ret;
@@ -263,7 +286,7 @@ bool __attribute__((nonnull)) cppQueue::peekIdx(void * const record, const uint1
263286 pStart = queue + (rec_sz * idx);
264287 }
265288
266- memcpy (record, pStart, rec_sz);
289+ ( void ) memcpy (record, pStart, rec_sz);
267290 }
268291
269292 return ret;
0 commit comments