patacongo commented on code in PR #11351: URL: https://github.com/apache/nuttx/pull/11351#discussion_r1422869723
########## mm/mempool/mempool.c: ########## @@ -46,43 +46,56 @@ * Private Functions ****************************************************************************/ -static inline FAR sq_entry_t *mempool_remove_queue(FAR sq_queue_t *queue) +static inline FAR dq_entry_t * +mempool_remove_queue(FAR struct mempool_s *pool, FAR dq_queue_t *queue) { - if (!sq_empty(queue)) - { - FAR sq_entry_t *entry = queue->head; + FAR dq_entry_t *ret = queue->tail; - queue->head = entry->flink; - return entry; - } - else + if (ret) { - return NULL; - } -} - -static inline size_t mempool_queue_lenth(FAR sq_queue_t *queue) -{ - FAR sq_entry_t *node; - size_t count; + FAR dq_entry_t *prev = ret->blink; + if (prev == NULL) + { + queue->head = NULL; + queue->tail = NULL; + } + else + { + pool->check(pool, prev); + queue->tail = prev; + prev->flink = NULL; + } - for (node = queue->head, count = 0; - node != NULL; - node = node->flink, count++); + ret->flink = NULL; + ret->blink = NULL; + } - return count; + return ret; } -static inline void mempool_add_queue(FAR sq_queue_t *queue, +static inline void mempool_add_queue(FAR dq_queue_t *queue, FAR char *base, size_t nblks, size_t blocksize) { while (nblks-- > 0) { - sq_addfirst((FAR sq_entry_t *)(base + blocksize * nblks), queue); + dq_addfirst((FAR dq_entry_t *)(base + blocksize * nblks), queue); } } +static size_t mempool_dq_count(FAR dq_queue_t *queue) +{ + FAR dq_entry_t *entry; + size_t count = 0; + + dq_for_every(queue, entry) + { + count++; + } Review Comment: > If c89 must be enforced, --std=c89 must be added to ci, otherwise the violation can happen daily. Only common code needs to be c89. That is code which could be used with older or less capable compilers. The correct way to inline is to include compler.h and to use the definitions provided there. There is a problem with the current inline definitions there: The definitions need to vary with selected C version. The current definitions in compiler.h are not no use for cases like this. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org